Fatal error: Call to undefined function insert() in C:wamp/www/app/models/users_model.php on line 48 |
[eluser]cobolCowboy[/eluser]
:grrr: CI v.2.1.0 Apache v2.2.21 PHP v5.3.10 MySQL v5.5.20 I'm trying to insert the new registration data on the 'users' table. the form passes validation: Code: If ($this->form_validation->run() === FALSE) : So from here, we go to the users_model insert function. Code: class Users_model extends CI_Model { and despite auto-loading the database library, and setting active record to TRUE I continue to get this error; here is my var_dump($this) together with the base path whic is correct the error message I'm getting. Quote:object(Users_model)[18] line 48 in the users_model: Code: $this->db>insert('users', $this); It's prolly something stupid. I just can't see it.
[eluser]InsiteFX[/eluser]
It's expecting an associate array to be passed to it not an object, $this is an object that's why you are getting the error! Change $this to $data. Or read the CodeIgniter Users Guide on how to pass an object.
[eluser]aquary[/eluser]
CI' AR do accept object for inserting, although using $this for inserting might cause error, but it was not related to this case. cobolCowboy, look closely at the line with error. Code: $this->db>insert('users', $this); Have you seen a character missing ? something after "db"......The error message is already clear. "Call to undefined function insert()".... Anyway, in this format, as I stated earlier, you might got an error in the query of PHP error. Due to $this itself refer to the users model itself... which contains all the methods. It may or may not be error since this is a weird case I've never done/seen before, but I'd suggest you to create a new variable instead, like $insert or $user.
[eluser]Abdul Malik Ikhsan[/eluser]
try to change insert() function in model to another for avoid collision function, for example : Code: public function insertIntoTable($data)
[eluser]cobolCowboy[/eluser]
okay Gang, Just flew back in, and boy are my arms tired!! Everybody was a little correct, and here's the original culprit line in the model. Code: $this->db>insert('users', $this); there was a missing dash. V Code: $this->db->insert('users', $this); Many thanks, |
Welcome Guest, Not a member yet? Register Sign In |