Page 1 of 1

MYSQL QUERY

Posted: Sun Jun 19, 2005 4:42 am
by Parody
I have a mysql query that selects something from the database and outputs it as a variable. It is a number and when outputed holds the value 'Resource id #5'. The row in the table is not fifth. And overall holds no significance (that i can see) to the number 5. This is the query:

Code: Select all

$query1455 = "SELECT mything FROM stats WHERE username= '$user'";
$user is a session that I set as a variable :)

Any ideas please?

Posted: Sun Jun 19, 2005 6:31 am
by timvw
You've probably forgotten to fetch data from the resultset resource...

Code: Select all

$query = "SELECT mything FROM stats WHERE username='$username'";
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_assoc($result);
if ($row)
{
  print_r($row);
}
else
{
  echo "no data was returned";
}