Re: comparing a variable to value in DB

From: Date: Mon, 29 Jul 2002 19:23:13 +0000
Subject: Re: comparing a variable to value in DB
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-110224@lists.php.net to get a copy of this message
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."; exit; } To check for blank fields simply ask "... WHERE username = ''". -Kevin ----- Original Message ----- From: "Tyler Durdin" <linuxgeek23@hotmail.com> To: <php-general@lists.php.net> 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 session > 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 do > 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 >

« previous php.general (#110224) next »