Jump to content

resource id #


Noctagon

Recommended Posts

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:

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

echo "$result";[/code]

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 :)
Link to comment
Share on other sites

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:

[code]
$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>";
}
[/code]
Link to comment
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.