这个sql语句为什么总是执行失败呢
$idinfo=mysql_fetch_array("select * from tb_yonghu where name='$name' and id='$id'")or die("访问失败");
是语句本身问题 ? 另外 $name 和 $id 加不加单引号有关系吗?
在前面echo了 $name 和 $id 都有值而且和数据库中的值是一样的
为什么 总是显示访问失败呢
数据库连接应该没问题 因为如果有问题就会显示数据库链接失败了
------解决方案--------------------
die("访问失败")表示只要mysql_fetch_array执行不成功就会显示“访问失败”,因此你不能下结论说数据库连接没有问题。
------解决方案--------------------
看看手册吧,mysql_fetch_array是执行资源,不是语句。
$rs=mysql_query("select * from tb_yonghu where name='$name' and id='$id'")or die("访问失败");
$idinfo=mysql_fetch_array($rs);
<br><font color="#e78608">------解决方案--------------------</font><br>执行SQL的函数是mysql_query() , 你自己上官网先下个PHP_MANUAL看熟吧。
<br><font color="#e78608">------解决方案--------------------</font><br><br>手册要随身携带。。。 <div class="clear"></div>
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号