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 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 R语言卸载之后无法重装,显示电脑存在下载某些较大二进制文件行为,怎么办
  • ¥15 java 的protected权限 ,问题在注释里