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

WBOY
Release: 2016-06-13 13:09:27
Original
1056 people have browsed it

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]'";

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!