Simple Question

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Simple Question

Postby GuitarNerd » 24. March 2005 10:33

just wondering how to tell if a query return from mysql is null for example if a user tries to login and enters a name that doesnt exist:

Code: Select all
$query = "SELECT * FROM user_table WHERE user = '$name'";
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
         
         if ($result == ??????){
         echo "This user does not exist");
         }


how do i check for no return?

Thanks[/code]
GuitarNerd
 
Posts: 4
Joined: 23. March 2005 19:17

Re: Simple Question

Postby boppy » 24. March 2005 16:02

Hi Eric,

try that:
Code: Select all
$query = "SELECT * FROM user_table WHERE user = '$name'";
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
         
if (mysql_num_rows($result)==0){
   echo("This user does not exist");
}
...in diesem Sinne
yours boppy

Interpunktion und Orthographie dieses Beitrags sind frei erfunden.
Eine Übereinstimmung mit aktuellen oder ehemaligen Regeln wäre rein zufällig und ist nicht beabsichtigt.
User avatar
boppy
AF Moderator
 
Posts: 501
Joined: 27. December 2002 02:15
Location: W-E-City

Postby GuitarNerd » 24. March 2005 16:26

thanks so much works like a charm
GuitarNerd
 
Posts: 4
Joined: 23. March 2005 19:17


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 172 guests