PHP 资源 ID #4 [英] PHP resource id #4

查看:47
本文介绍了PHP 资源 ID #4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我还是个 php 和 mysql 的新手.过去几天我一直在试图弄清楚这一点并在网上寻找答案,但就是无法让这个愚蠢的事情发挥作用......我有一个游戏网站(http://houston-by-night.com),人们登录,输入他们的字符表,然后应该可以再次拉起该表之后.现在,代码运行良好,按预期拉起页面,然后突然在 2015 年 4 月 29 日,它停止工作并开始给我资源 ID #4".

I'm still a novice with php and mysql. I've spent the last several days trying to figure this out and searching the net for answers, but just can't get this stupid thing working... I have a gaming site (http://houston-by-night.com), people log on, input their character sheet, and are supposed to be able to pull up the sheet again later. Now, the code was working fine, pulled up the page like it is supposed to, then suddenly on 4/29/15, it stopped working and starting giving me the "Resource id #4".

所以……代码如下:

$sql="SELECT * FROM topdata a, venuetop b, stats c, mid_data d, influence e, botdata f, accounts g WHERE (a.char_name=b.char_name) AND (b.char_name=c.char_name) AND (c.char_name=d.char_name) AND (d.char_name=e.char_name) AND (e.char_name=f.char_name) AND (f.char_name=g.log_name) AND (a.char_name=\"$_POST[char_name]\")";
$result=mysql_query($sql) 
    or die ("Couldn't get character data.<br>".mysql_error()."<br>Please contact Savvannis with your login name, character name, the above error and the page address above.");
$row = mysql_fetch_array($result);
    echo $sql;
    echo $result;

以及网页上的结果:

SELECT * FROM topdata a, venuetop b, stats c, mid_data d, influence e, botdata f, accounts g WHERE (a.char_name=b.char_name) AND (b.char_name=c.char_name) AND (c.char_name=d.char_name) AND (d.char_name=e.char_name) AND (e.char_name=f.char_name) AND (f.char_name=g.log_name) AND (a.char_name="Monroe")Resource id #4

并且字符表是空白的... char_name 对于所选的表是正确的,html 部分在那里,但没有别的.

And the character sheet is blank... the char_name is correct for the sheet chosen, the html portion is there, but nothing else.

有人对我可以尝试进行哪些更改以获取信息以按预期方式提取并填充页面有任何想法吗??

Does anyone have any ideas on what changes I can try to get the information to pull up and populate the page as it's supposed to??

推荐答案

您得到 resource id #4 因为您的查询结果是一个资源.您需要从中提取结果/数据.

You're getting resource id #4 because your query result is a resource. You need to extract the results/data from it.

您正在尝试 echo 输出 $result,它永远不会保存从数据库中获取的值,它只会有查询的结果,要么是查询对象,要么是布尔值.

You're trying to echo out $result which won't ever hold the values fetched from the database, it'll only ever have the result of the query, either being the query object or a Boolean.

您要做的是查看您的 $row 变量:

What you want to do is look at your $row variable:

print_r($row);

这篇关于PHP 资源 ID #4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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