Reputation: 191
When I run the code below
$data = array(
'name' => $this->input->post('name'),
'recipe' => $this->input->post('recipe'),
'category_id' => $category_id,
'recipe_elements' => $this->input->post('recipe_elements'),
'country' => $this->input->post('country'),
'video' => $this->input->post('video'),
'img' => $img_name,
'vote' => $this->input->post('oy')
);
$this->db->insert('recipes',$data);
I get this error
A PHP Error was encountered Severity: 4096
Message: Object of class stdClass could not be converted to string Filename: mysql/mysql_driver.php Line Number: 552 Error Number: 1064You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' '
I already tried to change the input values but still getting the same error. Any help would be appreciated. How can I fix this?
Upvotes: 3
Views: 23223
Reputation: 3170
You're trying to convert an object
to a string
.Please make sure $category_id
and $img_name
is not an object
.
Take a look here this may help you. Object of class stdClass could not be converted to string
You can sse:$this->db->last_query();
which Returns the last query that was run (the query string, not the result). From where you can see easily your query string which also help you findout actual error.
Upvotes: 4