mySQL query returning Resource id #5(mySQL 查询返回资源 ID #5)
问题描述
我已经搜索了可能的解决方案.我尝试过循环以及尝试 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:mySQL 查询返回资源 ID #5


基础教程推荐
- Web 服务器如何处理请求? 2021-01-01
- 使用 scandir() 在目录中查找文件夹 (PHP) 2022-01-01
- php中的foreach复选框POST 2021-01-01
- php 7.4 在写入变量中的 Twig 问题 2022-01-01
- 如何在数学上评估像“2-1"这样的字符串?产生“1"? 2022-01-01
- PHPUnit 的 Selenium 2 文档到底在哪里? 2022-01-01
- 将变量从树枝传递给 js 2022-01-01
- php中的PDF导出 2022-01-01
- Yii2 - 在运行时设置邮件传输参数 2022-01-01
- 主题化 Drupal 7 的 Ubercart “/cart"页 2021-01-01