Home >Backend Development >PHP Tutorial >PDO连接数据库从SQLITE改为MYSQL的有关问题

PDO连接数据库从SQLITE改为MYSQL的有关问题

WBOY
WBOYOriginal
2016-06-13 10:52:44748browse

PDO连接数据库从SQLITE改为MYSQL的问题
请教一下
之前写了个小代码 用PDO连接SQLITE 一切正常
现在改为连接MYSQL 报错
Fatal error: Call to a member function fetch() on a non-object
提示没有fetch方法 该如何解决?

对应行代码:
$sql ="select * from url where long = '$_POST[url]'"; //查询网址是否已经在数据库中
$query = $db -> query($sql);
$row = $query -> fetch();

------解决方案--------------------
$sql ="select * from url where `long` = '$_POST[url]'";

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn