Mockers Posted March 16, 2007 Share Posted March 16, 2007 Hi...first day w/ php Ive connected to my mysql db, and now i need to loop through it or use some other method in order to find out if a username has already been used or not. Quote Link to comment Share on other sites More sharing options...
only one Posted March 16, 2007 Share Posted March 16, 2007 for registering???? <?php $query= mysql_query("SELECT user FROM users WHERE user='$user'"); $check = mysql_num_rows($query); if ($check>0) { echo "already in use"; }else{ lets the through... } ?> Quote Link to comment Share on other sites More sharing options...
Mockers Posted March 16, 2007 Author Share Posted March 16, 2007 I dont quite understand. What does mysql_num_rows() do? nvm i get it lol Quote Link to comment Share on other sites More sharing options...
per1os Posted March 16, 2007 Share Posted March 16, 2007 Returns the number of rows that the query returned. If it returned more than 1 row, there is a user with the name of $user in the database. Therefore if the number of rows the query returned is greater than 0 that username exists in the database. Quote Link to comment Share on other sites More sharing options...
only one Posted March 16, 2007 Share Posted March 16, 2007 it counts how many rows has that username then if there more than 0 rows it doesnt let it through.... 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.