我已经搜索了可能的解决方案.我尝试过循环以及尝试 mysql_fetch_assoc 和 mysql_fetch_array 的变体,但我仍然得到资源 ID #5: 0: 错误.
I've searched about possible solutions to this. and I've tried looping as well as trying the variants of mysql_fetch_assoc and mysql_fetch_array but I'm still getting the Resource id #5: 0: error.
这是我认为会产生错误的代码.
Here's my code which I think generates the error.
<?php
mysqlc();
$email = GetSQLValueString($_SESSION['user'], "text");
$query = sprintf("SELECT * FROM newmember WHERE email = %s",$email);
$res = mysql_query($query) or die('Query failed: ' . mysql_error() . "<br />
$sql");
$row = mysql_fetch_assoc($res);
?>
"Resource id #5: 0" 不是错误.这意味着您尝试 echo $res
而不是尝试使用 $row
变量,例如 $row[column] 用于 fetch_assoc,$row[0] 用于 fetch_row, fetch_array 中的一个/两个.
"Resource id #5: 0" is not an error. It means that you tried to echo $res
instead of trying to use the $row
variable, such as $row[column] for fetch_assoc, $row[0] for fetch_row, either/both for fetch_array.
其他答案解释mysql_fetch_*的使用
The other answers explain the use of mysql_fetch_*
此外,不推荐使用 mysql_*.您应该改用 mysqli_* 或 PDO 函数.
Also, mysql_* is deprecated. You should use mysqli_* or PDO functions instead.
这篇关于mySQL 查询返回资源 ID #5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!