Page 1 of 1

Check against mysql field

Posted: Tue Mar 22, 2005 10:14 pm
by Jim_Bo
Hi,

I am trying to check that a username exists before continung with the script .. With the code below it says invalid username .. when the name does exist in the database ..

Code: Select all

$sql_user_name_check = mysql_query("SELECT user_name FROM users WHERE user_name = '$user_name'"); 
  
$user_name_check = mysql_num_rows($sql_user_name_check); 

if($user_name_check == 0) 
{ 

echo "<b>Error</b>: Username doesn't exist .<p> <a href=\"../index.php?pages=compose\">BACK</a></p>"; 

return;
Im guesing its because username cant be set as user_name .. it must be username .. ?

The database field title is user_name ..

Thanks

Posted: Tue Mar 22, 2005 10:17 pm
by feyd
echo out the query string.

Posted: Tue Mar 22, 2005 10:27 pm
by Jim_Bo
Hi,

?? not sure what you mean .. I had the same setup using alias instead of user_name and that seemed to work fine ..

Thanks

Posted: Tue Mar 22, 2005 10:33 pm
by feyd

Code: Select all

echo "SELECT user_name FROM users WHERE user_name = '$user_name'";
:roll:

Posted: Tue Mar 22, 2005 11:00 pm
by Jim_Bo
Hi,

Omg .. forget I asked .. so easy to miss simple things .. Missed one variable in a form :oops:

Thanks ..