No trust me you're on the right track. You don't need the double ==
operator in the SQL query. Try something like this...
$query = "SELECT * FROM membersWHERE username = '$username'";
$result = mysql_query($query, $db);
if (mysql_num_rows($result) == 0)
echo "The username <i>$username</u> does not exist.";
To check for blank fields simply ask "... WHERE username = ''".
----- Original Message -----
From: "Tyler Durdin" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, July 29, 2002 12:46 PM
Subject: [PHP] comparing a variable to value in DB
> I have a column in my DB named username and i am trying to compare a
> ID called $username to the field in my DB called username. The way i had
> done it before was SELECT * from tablename WHERE Tablename.username ==
> $username, but this does not seem to be working is there a better way to
> this? Also, I would like to know how to tell if a field is blank. For
> example, if my SELECT statement comes back and there is no data in the
> username column how can i check for this?
> Send and receive Hotmail on your mobile device: http://mobile.msn.com
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php