dsbqfrr098575666 2013-11-27 19:55
浏览 62
已采纳

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

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: 1064

You 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?

  • 写回答

1条回答 默认 最新

  • dongre1907 2013-11-27 20:10
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 MCNP里如何定义多个源?
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏