Welcome Guest, Not a member yet? Register   Sign In
error in SQL syntax?
#11

[eluser]flaky[/eluser]
I'm assuming the second error is happening due to the third one. The first error I have no clue what it is without seeing some code.
#12

[eluser]InsiteFX[/eluser]
The first ERROR, the rest usally are from the first.

InsiteFX
#13

[eluser]anna16[/eluser]
@flaky here are the codes,

controller: site.php
Code:
<?php
class Site extends Controller
{
  public $data = array();

    //function __construct()
  function Site()
    {
        parent::Controller();
        $this->load->library('session');
        $this->load->helper('form');
    $this->load->helper('url');
    $this->load->model('membership/membership');
    }
  
  function register_form()
  {
    $data['error_message'] = "";
    $this->load->view('membership/register_form', $data);
  }


    function register_account()
    {
    $data['email'] = $this->input->post('email');
    $data['username'] = $this->input->post('username');  
    $data['password'] = $this->input->post('password');
    $data['confirm'] = 'no';

    //check email
        $query = $this->membership->check_email();
      if($query->num_rows() > 0) //if exist assign message as data
    {
        $data['error_message'] = "Sorry the email is already in used, please try again.";
    }
    else  //else proceed to check_username()
    {
        $data['error_message'] = "Nice, no one used this email yet";
    }      
  
    $this->load->view('membership/register_form', $data);    

    
    //check username

            
        //$this->membership->add_record($data);
    //$this->load->view('membership/register_success');
    }


/* These are function tests. */  
  function register_success()
  {
       $this->load->view('membership/register_success');
  }
  

}
//end of class

model: membership.php
Code:
<?php
class Membership extends Model
{

  function __construct()
  {
    parent::Model();
    $this->load->database();
  }

    function add_record($data)
    {
        $this->db->insert('user', $data);
        return;
    }
  
  function check_email()
  {
    $query = $this->db->query("SELECT email FROM user WHERE email='$this->input->post('email')'");
        return $query->result();
  }
  

  function check_username()
  {
    $query = $this->db->query("SELECT username FROM membership WHERE username='$this->input->post('username')");
    if ($query->num_rows() > 0)
    {
    
    }    
  }



/*    
    function get_records()
    {
        $query = $this->db->get('data2');
        return $query->result();
    }
    
    function update_record($data2)
    {
        $this->db->where('id', 12);
        $this->db->update('data2', $data2);
    }
    
    function delete_row()
    {
        $this->db->where('id', $this->uri->segment(3));
        $this->db->delete('data2');
    }
*/    
}
//end of membership_model
#14

[eluser]anna16[/eluser]
okay i will google.

thanks
#15

[eluser]Narkboy[/eluser]
[quote author="anna16" date="1290363649"]by the way can you guys explain I'm having 3 errors,
http://coder9.com/ci172x/index.php/membe...er_account

I'm confused which error should i fix first?

thanks in advanced.[/quote]

Error 1 - you're trying to do something with part of an object, but you're actually doing it to the object itself.

Error 2 - I'm guessing you have either whitespace before a <?php> tage somewhere, or it's because of 3.

Error 3 - The SQL server is being asked to look for a row in the user table that has - ->post('email') - as an email address. You've got a typo in your db call.

First - rewrite your db query to work properly - I'd suggest that you use Active Record. It makes life infinatly easier when you get your head around it.

Second - in membership.php on line 19 you'll find an echo or a string-related function that needs a string param. You're passing it the object rather than a variable within the object.

Smile




Theme © iAndrew 2016 - Forum software by © MyBB