bobocheez Posted August 14, 2009 Share Posted August 14, 2009 Hi, I have the following code and it will not check to see if a registering user inputs the same data as another user. The snippet: $query = 'SELECT username FROM users WHERE username = "$username"'; $result = mysql_query($query); $row = mysql_fetch_array($result, MYSQL_BOTH); if ($row['username'] == $username) { However, it does insert the entry so it is connected to the database. Thoughts? Link to comment https://forums.phpfreaks.com/topic/170312-solved-check-if-username-is-already-in-database-registration-form/ Share on other sites More sharing options...
mikesta707 Posted August 14, 2009 Share Posted August 14, 2009 just use mysql_num_rows $query = 'SELECT username FROM users WHERE username = "$username"'; $result = mysql_query($query); if (mysql_num_rows($result) > 0){ die("NO DICE. YOU ALREADY HERE!"); } Link to comment https://forums.phpfreaks.com/topic/170312-solved-check-if-username-is-already-in-database-registration-form/#findComment-898417 Share on other sites More sharing options...
bobocheez Posted August 14, 2009 Author Share Posted August 14, 2009 That does not work either. But I figured it out. The variable value has to be in double quotes.... So anyone else reading this, both codes will work if you just change the quotes " change to ' ' change to " Link to comment https://forums.phpfreaks.com/topic/170312-solved-check-if-username-is-already-in-database-registration-form/#findComment-898459 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.