我已经搜索了可能的解决方案.我尝试过循环以及尝试 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
在 SELECT(MYSQL/PHP) 中加入 2 个表Joining 2 tables in SELECT(MYSQL/PHP)(在 SELECT(MYSQL/PHP) 中加入 2 个表)
如何使<option selected=“selected">由How to make lt;option selected=quot;selectedquot;gt; set by MySQL and PHP?(如何使lt;option selected=“selectedgt;由 MySQL 和 PHP 设置?)
使用 PHP 中的数组自动填充选择框Auto populate a select box using an array in PHP(使用 PHP 中的数组自动填充选择框)
PHP SQL SELECT where like search item with multiple wordsPHP SQL SELECT where like search item with multiple words(PHP SQL SELECT where like search item with multiple words)
json_encode 从 MSSQL-SELECT 产生 JSON_ERROR_UTF8json_encode produce JSON_ERROR_UTF8 from MSSQL-SELECT(json_encode 从 MSSQL-SELECT 产生 JSON_ERROR_UTF8)
MySQL ORDER BY rand(),名称 ASCMySQL ORDER BY rand(), name ASC(MySQL ORDER BY rand(),名称 ASC)