Jump to content


Photo

resource id #


  • Please log in to reply
2 replies to this topic

#1 Noctagon

Noctagon
  • Members
  • PipPip
  • Member
  • 28 posts

Posted 02 October 2006 - 04:01 AM

Hi all,

I am pretty new to this stuff still and have done a bit of searching but can't make sense out of stuff yet.

I have code as follows:

$query = 'SELECT totals FROM alpha where UserID="1"';
	$result = mysql_query($query) or die('Query failed: ' . mysql_error());
	
	echo "$result";

I want it to look in the table called alpha at the column called totals and return me the entry where on the same row under the userid column the value is 1

I keep getting a resource id # result.......

How do I adjust things.

Thanks :)

#2 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 02 October 2006 - 04:18 AM

when you assign the query to a variable, the query returns a result source. It's like a magician's hat where it's dark and mysterious inside and you can pull out all kinds of crazy things like row data and rabbits and stuff.  So in order to pull the rabbit out of the hat, you must reach in and fetch it.  Here is one example of how to do that:

$query = 'SELECT totals FROM alpha where UserID="1"';
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
while ($list = mysql_fetch_array($result)) {
   echo $list['totals'] . "<br>";
}

Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#3 Noctagon

Noctagon
  • Members
  • PipPip
  • Member
  • 28 posts

Posted 02 October 2006 - 11:24 PM

Thankyou so much for your reply......exactly what I required........nice metaphor too as I am a magician ;)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users