Page 1 of 1

[SOLVED] Resource id #9

Posted: Wed Jul 07, 2004 3:51 pm
by FCB
I made a login where users enter their email and password, then i need the username to be returned, i expected $query to do that at the end there, but instead i get "Resource id #9" any ideas?

Code: Select all

<?php
function login($email,$pass)
{
  $conn = db_conn();
  if (!$conn)
  {
    return false;
  }
  else
  {
    $pass1 = crypt($pass,'ezp');
    $query = mysql_query("select name from users where email = '$email' and pass = '$pass1'");
    if (!mysql_num_rows($query)>0)
    {
      return 'Error: Login Failure';
    }
    else
    {
      return $query;
    }
  }
}
?>
Thanks!
~FCB

Posted: Wed Jul 07, 2004 3:57 pm
by markl999
You're missing a mysql_fetch_* function. Eg, something like :

Code: Select all

else
{
  $result = mysql_fetch_assoc($query);
  return $result['name'];
}

Posted: Wed Jul 07, 2004 4:18 pm
by FCB
thanks, that worked!!