Home >Backend Development >PHP Tutorial >我这个代码为什么打印不出来数据呢?

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

WBOY
WBOYOriginal
2016-06-06 20:18:041305browse

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

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