PDA

View Full Version : Cannot pull info from mysql -Resorce ID#4 (5,6)


aklilutsige
02-20-2008, 06:52 AM
Help me !! I'm trying to display one little pice of information form MySQL data base and it just doesn't seem to be working properly.it whows a Resource ID #4(sometimes 5 or 6)The database is connecting ok, it doesn't show an error message. Any help anyone can give me would be awesome!

Here is my code
function CakeUser($UserId,$password)
{
$Query = "SELECT `PrivilegeClass` FROM `userinfo` WHERE `UserID` = '$UserId' AND `Password` = '$password'";
$Result = mysql_query($Query) OR die(mysql_error());
echo "Privlage Class is ".$Result;
return $Result;
}

aklilutsige
02-20-2008, 06:53 AM
Help me!!

abduraooft
02-20-2008, 07:12 AM
You have to use mysql_fetch_array (http://in2.php.net/mysql_fetch_array) or something similar to retrieve the values,

rangana
02-20-2008, 07:13 AM
instead of directly returning the $result variable, you must first use 'mysql_fetch_row',
'mysql_fetch_array','mysql_fetch_assoc' or something similar.
it could be something like:

function CakeUser($UserId,$password)
{
$Query = "SELECT `PrivilegeClass` FROM `userinfo` WHERE `UserID` = '$UserId' AND `Password` = '$password'";
$Result = mysql_query($Query) OR die(mysql_error());
$row=mysql_fetch_array($Result);
return $row;
}

this means that the variable $row is an array which holds the values from the database.
Click here (http://us3.php.net/manual/en/ref.mysql.php) for a more info.

See if it helps :D