Ok man, now u got me to show you the whole code 🙂 I am sure that my $returned_id[user_id] is not empty. Here is the whole function. I use this function to get me data from mySQL regarding users. Yeah, users i said.. because I'm building a portal myself 🙂
Anyway, so the function below is supposed to return:
1- If a user exists (return "valid") and
2- If a user exists, return me his/her ID.
The function follows:
function checkIfUserExists( $login )
{
global $link;
$result = mysql_query( "SELECT user_id, username FROM users WHERE username='$login'",$link );
if ( mysql_fetch_array($result) )
{
$valid = "valid";
$returned_id = $result[user_id];
return array($valid, $returned_id);
}
else
{
$valid = "invalid";
return ($valid);
}
}
$myarray = checkIfUserExists($login);
print "$myarray[0]"; //this prints accordingly
print "$myarray[1]"; //does not even print
This is what I did. The first value of the array (the valid/invalid) thing works perfectly. But the second and last value of the array does is empty for some reason. Just to make sure, I checked on my DB to see if there REALLY is a user_id, and yes there is a user_id and it is set to 1 (the 1st user)... Please help me out.
Ilir