当我运行下面的代码时
$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);
我收到这个错误
遇到PHP错误严重性:4096
消息:类stdClass的对象无法转换为字符串文件名:mysql/mysql_driver.php行号:552错误编号:1064您的SQL语法有错误;查看与MySQL服务器版本相对应的手册,了解在"附近使用的正确语法
我已经尝试更改输入值,但仍然得到相同的错误。如有任何帮助,我们将不胜感激。我该怎么解决这个问题?
您正在尝试将object
转换为string
。请确保$category_id
和$img_name
不是object
。
看看这里,这可能会对你有所帮助。类stdClass的对象无法转换为字符串
您可以sse:$this->db->last_query();
,它返回上次运行的查询(查询字符串,而不是结果)。从那里你可以很容易地看到你的查询字符串,这也可以帮助你找出实际的错误。