PDA

View Full Version : Resource id #4 error


MrMe
10-21-2009, 08:50 AM
I am trying to build an inventory list for my website. I attempt to retrieve the information and all i get is "Resource id #4 Resource id #5 Resource id #6 Resource id #7 Resource id #8 Resource id #9 Resource id #10 Resource id #11 Resource id #12 "
<?php
$con = mysql_connect("HOST","USER","PASS");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("DB", $con);
$equip = mysql_query("SELECT * FROM TABLE1 WHERE name=$_SESSION['user'];");
$equiped = mysql_fetch_array($equip);



$wep1 = mysql_query("SELECT pic FROM table2 where id='$equiped[wep1]'");
$gloves = mysql_query("SELECT pic FROM table2 where id='$equiped[gloves]'");
$ring1 = mysql_query("SELECT pic FROM table2 where id='$equiped[ring1]'");
$helm = mysql_query("SELECT pic FROM table2 where id='$equiped[helm]'");
$body = mysql_query("SELECT pic FROM table2 where id='$equiped[body]'");
$belt = mysql_query("SELECT pic FROM table2 where id='$equiped[belt]'");
$ring2 = mysql_query("SELECT pic FROM table2 where id='$equiped[ring2]'");
$wep2 = mysql_query("SELECT pic FROM table2 where id='$equiped[wep2]'");
$boots = mysql_query("SELECT pic FROM table2 where id = '$equiped[boots]'");

?>

and the code to display it is,
<html>
<style>

img {
background-color: yellow;
}
</style>
<body><center>
<table border="0" width="50%" cellpadding="0">
<tr>

<td valign="right">
<br><br>
<?php
Print "
<img src=$wep1 width=\"100\" height=\"200\" alt=\"Wep Slot1\"><br><br>
<img src=$gloves width=\"100\" height=\"100\" alt=\"Gloves\">";
?>
</td>

<td valign="top">
<br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br>
<?php
Print "<img src=$ring1 width=\"50\" height=\"50\" alt=\"R1\"> ";
?>
</td>
<td valign="top">
<?php
Print "<img src=$helm width=\"100\" height=\"100\" alt=\"Helm\"><br><br>
<img src=$body width=\"100\" height=\"200\" alt=\"Body\"><br><br>
<img src=$belt width=\"100\" height=\"50\" alt=\"Belt\">";
?>
</td>
<td valign="top">
<br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br>
<?php
Print "<img src=$ring2 width=\"50\" height=\"50\" alt=\"R2\">";
?>
</td>
<td valign="top">
<br><br>
<?php
Print "<img src=$wep2 width=\"100\" height=\"200\" alt=\"Wep Slot 2\"><br><br>
<img src=$boots width=\"100\" height=\"100\" alt=\"Boots\">";
?>
</td>
</tr>
</table>

</body>
</html>

All the images are broken and i tryed using

Print "
$wep1
$gloves
$ring1
$helm
$body
$belt
$ring2
$wep2
$boots
";
to display the info and got "Resource id #4 Resource id #5 Resource id #6 Resource id #7 Resource id #8 Resource id #9 Resource id #10 Resource id #11 Resource id #12 "

I really need some help!

abduraooft
10-21-2009, 09:23 AM
I really need some help! You need to add proper error checks to your queries, like mysql_query(....) or die(mysql_error());
and then fetch the values from mysql query result using functions like mysql_fetch_row/_array etc. Check the manual for samples.

atheistrical
10-25-2009, 12:36 PM
$wep1 = mysql_query("SELECT pic FROM table2 where id='$equiped[wep1]'");
$gloves = mysql_query("SELECT pic FROM table2 where id='$equiped[gloves]'");
$ring1 = mysql_query("SELECT pic FROM table2 where id='$equiped[ring1]'");
$helm = mysql_query("SELECT pic FROM table2 where id='$equiped[helm]'");
$body = mysql_query("SELECT pic FROM table2 where id='$equiped[body]'");
$belt = mysql_query("SELECT pic FROM table2 where id='$equiped[belt]'");
$ring2 = mysql_query("SELECT pic FROM table2 where id='$equiped[ring2]'");
$wep2 = mysql_query("SELECT pic FROM table2 where id='$equiped[wep2]'");
$boots = mysql_query("SELECT pic FROM table2 where id = '$equiped[boots]'");

I am giving you the basic idea which may help you understand. Assuming that the above queries run without errors. All that you need to add are:

$wep1 = mysql_query("SELECT pic FROM table2 where id='$equiped[wep1]'");
$temp=mysql_fetch_row($wep1);
$wep1=$temp[0];
$gloves = mysql_query("SELECT pic FROM table2 where id='$equiped[gloves]'");
$temp=mysql_fetch_row($gloves);
$gloves=$temp[0];
$ring1 = mysql_query("SELECT pic FROM table2 where id='$equiped[ring1]'");
$temp=mysql_fetch_row($ring1);
$ring1=$temp[0];
$helm = mysql_query("SELECT pic FROM table2 where id='$equiped[helm]'");
$temp=mysql_fetch_row($helm);
$helm=$temp[0];
$body = mysql_query("SELECT pic FROM table2 where id='$equiped'");
[B]$temp=mysql_fetch_row($body);
$body=$temp[0];
$belt = mysql_query("SELECT pic FROM table2 where id='$equiped'");
[B]$temp=mysql_fetch_row($belt);
$belt=$temp[0];
$ring2 = mysql_query("SELECT pic FROM table2 where id='$equiped[ring2]'");
$temp=mysql_fetch_row($ring2);
$ring2=$temp[0];
$wep2 = mysql_query("SELECT pic FROM table2 where id='$equiped[wep2]'");
$temp=mysql_fetch_row($wep2);
$wep2=$temp[0];
$boots = mysql_query("SELECT pic FROM table2 where id = '$equiped'");
[B]$temp=mysql_fetch_row($boots);
$boots=$temp[0];

Now try the following and let me know how that looks like!

Print "
$wep1
$gloves
$ring1
$helm
$body
$belt
$ring2
$wep2
$boots
";

MrMe
11-22-2009, 12:55 PM
sorry for the late reply but it worked :thumbsup: i had to finish placing it into the page its being developed for and that took a long long time and a lot of trial and error when multiple variables such as if they have anything equipped and such but it works at last. :p Thanks atheistrical!