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? Quote Link to comment 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!"); } Quote Link to comment 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 " Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.