Call to a member function fetch() on a non-object错误
try{
$dsn = "mysql:host=localhost;dbname=db_upan";
$db = new PDO($dsn,"root","");
$sql = "select * form tb_uptype";
$statement = $db->query($sql);
while($result = $statement->fetch(PDO::FETCH_ASSOC )){
echo $result['genrename'];
}
$db = null;
}catch (PDOException $e){
echo "发生错误。";
}
代码如上: 运行的时候提示错误Fatal error: Call to a member function fetch() on a non-object in C:\xampp\htdocs\upan\test.php on line 7;
请问这是什么原因啊? 坐等。。。

------解决方案--------------------
$sql = "select * from tb_uptype";
------解决方案--------------------
$sql = "select * form tb_uptype";
应为
$sql = "select * from tb_uptype";

sql 指令错了,自然后继代码也要出错

09-10 20:03