Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/246.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 消息:类stdClass的对象无法在codeigniter中转换为字符串_Php_Mysql_Database_Codeigniter - Fatal编程技术网

Php 消息:类stdClass的对象无法在codeigniter中转换为字符串

Php 消息:类stdClass的对象无法在codeigniter中转换为字符串,php,mysql,database,codeigniter,Php,Mysql,Database,Codeigniter,当我运行下面的代码时 $data = array( 'name' => $this->input->post('name'), 'recipe' => $this->input->post('recipe'), 'category_id' => $category_id, 'recipe_elements' => $t

当我运行下面的代码时

  $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服务器版本对应的手册,以了解要使用的正确语法


我已经尝试更改输入值,但仍然得到相同的错误。任何帮助都将不胜感激。如何解决此问题?

您正在尝试将
对象
转换为
字符串
。请确保
$category\u id
$img\u name
不是
对象

看看这里,这可能对你有帮助


您可以使用sse:
$this->db->last_query()感谢您的回复。似乎我在定义$category\u id变量时犯了一个错误。