Jump to content


Photo

Resource id #18


  • Please log in to reply
4 replies to this topic

#1 Leovenous

Leovenous
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 26 June 2006 - 06:59 PM

I don't know how much php is involved. This may belong in the SQL area.

Anyway, this frusterates me. Its not unusual for me to encounter resource id issues and hours of searching has yielded very little result. Maybe I have a wrong approach or something, I would like to learn.

So this query:

$query = "SELECT frc_id FROM frc_users WHERE frc_id = '$userid' "; 
$result = mysql_query ($query) or die(mysql_error()); 
echo $query;    
echo $result;

I get the right query:

SELECT frc_id FROM frc_users WHERE frc_id='2'

But the result is the resource id #18. What gives?

#2 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 26 June 2006 - 07:53 PM

Try:
print_r($result);

Orio.
Think you're smarty?

(Gone until 20 to November)

#3 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 26 June 2006 - 07:59 PM

You cant echo $result in its raw state. You have to use a function like mysql_fetch_array in order to get the results. $result justs stores the result resource which is loaded into memory.

So if you do this:
$rows = mysql_fetch_array($result);

echo print_r($rows);

You'll now see your results.


#4 Leovenous

Leovenous
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 26 June 2006 - 10:04 PM

That makes sense. I wondered if it had to do with an array. Thanks

#5 hackerkts

hackerkts
  • Members
  • PipPipPip
  • Advanced Member
  • 593 posts
  • LocationSingapore
  • Age:18

Posted 27 June 2006 - 09:14 AM

$rows = mysql_fetch_array($result);
Is for calling one/zero row, if you want to call more more rows, you need to use while loop.

There's a FAQ which is sticky, try reading there. It has examples.

Regards,
hackerkts

To be a coder, you must learn how to think and not to give up so easily.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users