php - 我这个代码为什么打印不出来数据呢?
本文介绍了php - 我这个代码为什么打印不出来数据呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
id也是有值的 数据库里面也有数据 也没有报错的地方为什么就是打印不出来数据呢?
<?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'];
}
?>
解决方案
$stmt=$pdo->prepare("select id,name,content from reply where reid=?");
name
字段不存在,改为reid
这篇关于php - 我这个代码为什么打印不出来数据呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文