[SOLVED] Resource id #9

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
FCB
Forum Newbie
Posts: 8
Joined: Mon Jun 21, 2004 6:12 pm

[SOLVED] Resource id #9

Post 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
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

You're missing a mysql_fetch_* function. Eg, something like :

Code: Select all

else
{
  $result = mysql_fetch_assoc($query);
  return $result['name'];
}
FCB
Forum Newbie
Posts: 8
Joined: Mon Jun 21, 2004 6:12 pm

Post by FCB »

thanks, that worked!!
Post Reply