IT技术学习网
IT技术学习网
您的位置: 主页 > 编程技术 > php >

Call to a member function query() on a non-object in原因

2015-01-17 11:13 来源: IT技术学习网原创 阅读:

本文给大家讲述php连接数据库报错"Fatal error: Call to a member function query() on a non-object in"的原因。

在用php查询数据库的时候,小编遇到报错如下:

Fatal error: Call to a member function query() on a non-object in D:\test\edit.php on line 16

经过检查,找到问题原因:

$dbh->query("SELECT * from tb_name")

我这句中的$dbh是不存在的。

请注意$dbh必须先创建,如:

$dbh=new PDO('mysql:host=127.0.0.1; dbname=dbname','username','password');

Call to a member function query() on a non-object in原因
转载需注明出处:IT技术学习网 http://www.itjsxx.com/php/Call_to_a_member_function_query.html

标签:
评论文章 Call to a member function query() on a non-object in原因
评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)
  • 梦瑶
    2015-12-03 03:14:19发表

    谢谢分享了!

  • 匿名
    2015-10-07 15:09:23发表

    is well known that colon cancer is a common malignant tumor in the life, the possibility of complete cure is almost zero, but the knowledge of other aspects of the disease, but few to understand. Oper

IT技术学习网 - 关于我们 - 联系我们 - 版权声明 - 网站地图