您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息
三六零分类信息网 > 邵阳分类信息网,免费分类信息发布

php 预编译查询始终fetch不到数据解决方案

2025/12/25 4:06:54发布26次查看
php 预编译查询始终fetch不到数据
include ('../db/mysqlconnect.php');
$conn = new mysqlconnect();
$mysqli = $conn->getconnection();
$sql = 'select id, username, password from admin where id = ?';
$seach_id = 1;
settype($seach_id, integer);
if($stmt = $mysqli->prepare($sql)) {
$stmt->bind_param('i', $seach_id);
$stmt->execute();
$stmt->bind_result($rs_id, $rs_name, $rs_password);
if($stmt->fetch() == null) {
echo 'no result';
} else {
printf('id:%s, name:%s, password:%s
', $rs_id, $rs_name, $rs_password);
}
$stmt->close();
$mysqli->close();
}

sql语句明明可以查询出来数据, 我使用php的非预编译语句($result = $mysqli->query($query);)也可以查询出来记录, 就是上面的查询代码始终在fetch出抓取不到数据,我的php版本是php-5.2.5-x64, 环境是64位的win7, 有遇到过的朋友或知道的能给分析一下么, 我已经困扰2天了....谢谢了
php prepare fetch 分享到: getconne... data-pics=>
------解决方案--------------------
代码看上去没有问题
但如果直接复制你的代码就无法通过语法检查
------解决方案--------------------
http://www.php.net/manual/en/mysqli.prepare.php
------解决方案--------------------
http://xiaobo-liu.iteye.com/blog/1288008
------解决方案--------------------
settype($seach_id, integer);
可以省略
------解决方案--------------------
什么输出都没有?先确认进入if了没有?
邵阳分类信息网,免费分类信息发布

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product