mySQL 查询返回资源 ID #5

mySQL query returning Resource id #5(mySQL 查询返回资源 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)