Jump to content

Recommended Posts

with my code it gives resource id# 16 or whatever it is and nomally to change it to the value i would use $blah = $row['name']; but for some reason it gives blank, but i know that it is not blank so heres my code:

 

<?php
$enemy_id = $_SESSION['enemy_id'];
// Work out enemy drops
$enemy_query = mysql_query("SELECT `drop1` FROM `Enemies` WHERE `id`='$enemy_id'");
$row = @mysql_fetch_assoc($enemy_query) or die("Invalid query, please contact an administrator!");
list($table1, $id1) = split("_", $row['drop1']);
$array = array('Body','Hats','Items','Pants','Weapons');
sort($array);
foreach ($array as $key => $table1)
{
$drop1 = "SELECT `id` FROM `$table1` WHERE `id`='$id1'";
$drop1 = mysql_query($drop1) or die(mysql_error() . ' ON Query ' . $drop1);
}
?>

 

Thanks,

 

~ Chocopi

Link to comment
https://forums.phpfreaks.com/topic/54015-solved-resource-id/
Share on other sites

Nevermind it wasnt working as:

 

<?php
$enemy_id = $_SESSION['enemy_id'];
// Work out enemy drops
$enemy_query = mysql_query("SELECT `drop1` FROM `Enemies` WHERE `id`='$enemy_id'");
$row = @mysql_fetch_assoc($enemy_query) or die("Invalid query, please contact an administrator!");
list($table1, $id1) = split("_", $row['drop1']);
$array = array('Body','Hats','Items','Pants','Weapons');
sort($array);
foreach ($array as $key => $table1)
{
$drop1 = "SELECT `id` FROM `$table1` WHERE `id`='$id1'";
$drop1 = mysql_query($drop1) or die(mysql_error() . ' ON Query ' . $drop1);
}
?>

 

should have been

<?php
$enemy_id = $_SESSION['enemy_id'];
// Work out enemy drops
$enemy_query = mysql_query("SELECT `drop1` FROM `Enemies` WHERE `id`='$enemy_id'");
$row = @mysql_fetch_assoc($enemy_query) or die("Invalid query, please contact an administrator!");
list($table1, $id1) = split("_", $row['drop1']);
$array = array('Body','Hats','Items','Pants','Weapons');
sort($array);
foreach ($array as $key => $table1)
{
$drop1 = mysql_query("SELECT `id` FROM `$table1` WHERE `id`='$id1'");
$drop1 = mysql_fetch_assoc($drop1) or die(mysql_error() . ' ON Query ' . $drop1);
$drop1 = $drop1['id'];
}
?>

Link to comment
https://forums.phpfreaks.com/topic/54015-solved-resource-id/#findComment-267057
Share on other sites

if the resource id #16 is returned and not the data then you have not made a fetch statement

<?php
$query = "SELECT * table ";
$answer = mysql_query($query) of die ("Cannot get the stuff" . mysql_error());

echo $answer; //would output Resource id# 16 or some such number

$row = mysql_fetch_row($answer);

echo $row[0]; //would out put the first key in the row

?>

Link to comment
https://forums.phpfreaks.com/topic/54015-solved-resource-id/#findComment-267061
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.