I'm trying to select data from mySQL database using PHP and I encountered one problem. When I printed out the result after selecting data, it printed out "Resource ID #5" instead of the actual data. How can I fix this problem. Below is my code. It is really simple that I don't understand where the problem is. Please help.

$linkID = mysql_connect($host, $db_user, $db_pass);
mysql_select_db("$database", $linkID);
$result = mysql_query("SELECT password FROM logins WHERE username = '$user'", $linkID);
$pass = mysql_fetch_row($result);

if ($pass[0] === (Encrypt($password))) {
$cusid = mysql_query("SELECT cusid FROM logins WHERE username = '$user'", $linkID) or die(mysql_error()); //the problem is this line here
$SESSION['cusid'] = $cusid;
$
SESSION['username'] = $user;
$_SESSION['logged'] = true;
}
else
echo "Either your username or password is incorrect. Please check and reenter them again.";

mysql_close($linkID);

    Did you try and print out $linkID or $result? Those are resources. In your code you would print out $pass[0] to get useful info.

    PS when posting anything more than a line or two put your code within

     tags, and when you get results use the thread tools to make it resolved.

      Well you have to use mysql_fetch_row or similar like you did in the first query. But why are you doing 2 querys? You could manage with one:

      $linkID = mysql_connect($host, $db_user, $db_pass);
      mysql_select_db("$database", $linkID);
      $result = mysql_query("SELECT cusid FROM logins WHERE username = '$user' AND password='".Encrypt($password)."'", $linkID);
      if (mysql_num_rows($result)==1) {
      	$cusid=mysql_result($result,0);
      	$_SESSION['cusid'] = $cusid;
      	$_SESSION['username'] = $user;
      	$_SESSION['logged'] = true;
      } else {
      	echo "Either your username or password is incorrect. Please check and reenter them again.";
      }
      
      mysql_close();
      
        $linkID = mysql_connect($host, $db_user, $db_pass) or exit(mysql_error());
        mysql_select_db($database, $linkID) or exit(mysql_error());
        $result = mysql_query("SELECT * FROM logins WHERE username = '$user' AND password = '" . Encrypt($password) . "'");
        if (mysql_num_rows($result))
        {
        	while ($row = mysql_fetch_assoc($result))
        	{
        		$_SESSION['cusid'] = $row['cusid']; 
        		$_SESSION['username'] = $user; 
        		$_SESSION['logged'] = true;
        	} 
        } 
        else
        {
        	echo 'no records found matching that username and password';
        }
        mysql_close($linkID);
        
          Write a Reply...