获取资源ID#3 MySql中的错误 [英] Getting Resource id #3 Error in MySql
本文介绍了获取资源ID#3 MySql中的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我运行这个代码,我有一个资源id#3错误,应该已经显示完整的电影表。
I ran this code and I got a Resource id #3 error where it should have showed the full movies table.
mysql_connect("localhost", "root", "password") or die(mysql_error());
mysql_select_db("treehouse_movie_db") or die(mysql_error());
$data = mysql_query("SELECT * FROM movies")
or die(mysql_error());
echo $data;
推荐答案
这不是一个错误
您的查询正在执行,您正在从获取适当的资源 mysql_query()
,因为应该返回。
This is not an error
Your query is getting executed and you are getting appropriate resource from mysql_query()
as it should be returned.
要获得响应, a href =http://www.php.net/manual/en/function.mysql-fetch-array.php =nofollow> mysql_fetch_array()
或 mysql_fetch_assoc()
To get the response you have to use mysql_fetch_array()
or mysql_fetch_assoc()
mysql_connect("localhost", "root", "password") or die(mysql_error());
mysql_select_db("treehouse_movie_db") or die(mysql_error());
$data = mysql_query("SELECT * FROM movies")
or die(mysql_error());
while($row = mysql_fetch_assoc($data))
{
print_r($row);
}
SUGGESTION: mysql_ *尝试切换到 mysqli_ * 或 PDO
SUGGESTION: mysql_* are no longer maintained .Try switching to mysqli_* or PDO
这篇关于获取资源ID#3 MySql中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文