mySQL查询返回资源ID#5 [英] mySQL query returning Resource id #5

查看:58
本文介绍了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 />\n$sql");
            $row = mysql_fetch_assoc($res);
    ?>  


推荐答案

资源ID#5:0不是错误。这意味着您尝试使用 echo $ res 而不是尝试使用 $ row 变量,例如$ row [列] for fetch_assoc,$ row [0] for fetch_row,/ / both for 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆