Home  >  Article  >  Backend Development  >  这样写为什么获取不到数据?

这样写为什么获取不到数据?

WBOY
WBOYOriginal
2016-06-23 13:19:22998browse

mysql_fetch_array不就是获取一行数据吗  为什么获取不到  还提示这个内容
( ! ) Warning: mysql_fetch_array() expects parameter 1 to be resource, object given in D:\wamp\www\chaxun.php on line 5

 $pdo=new PDO("mysql:host=localhost;dbname=t1","root","");
 $stmt=$pdo->prepare("select * from test");
 $stmt->execute();
 $myrow = mysql_fetch_array($stmt);
 print_r($myrow);
?>


回复讨论(解决方案)

$myrow = mysql_fetch_array($stmt);
应为
$myrow = $stmt->fetch();

xi

$myrow = mysql_fetch_array($stmt);
应为
$myrow = $stmt->fetch();


谢谢
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