首頁  >  文章  >  後端開發  >  我这个代码为什么打印不出来数据呢?

我这个代码为什么打印不出来数据呢?

WBOY
WBOY原創
2016-06-06 20:18:041258瀏覽

id也是有值的 数据库里面也有数据 也没有报错的地方为什么就是打印不出来数据呢?
我这个代码为什么打印不出来数据呢?

<code><?php $id2=$_GET['id'];
   $pdo=new PDO("mysql:host=localhost;dbname=t1","root","");
   $stmt=$pdo->prepare("select id,name,content from reply where reid=?");
   $stmt->execute(array($id2));
   $res1=$stmt->fetchall(PDO::FETCH_ASSOC);
    foreach($res1 as $v2){
      echo $v2['content'];
     }
   ?></code>

回复内容:

id也是有值的 数据库里面也有数据 也没有报错的地方为什么就是打印不出来数据呢?
我这个代码为什么打印不出来数据呢?

<code><?php $id2=$_GET['id'];
   $pdo=new PDO("mysql:host=localhost;dbname=t1","root","");
   $stmt=$pdo->prepare("select id,name,content from reply where reid=?");
   $stmt->execute(array($id2));
   $res1=$stmt->fetchall(PDO::FETCH_ASSOC);
    foreach($res1 as $v2){
      echo $v2['content'];
     }
   ?></code>

<code>$stmt=$pdo->prepare("select id,name,content from reply where reid=?");</code>

name字段不存在,改为reid

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn