avillanu Posted August 6, 2007 Share Posted August 6, 2007 I'm in the process of building a user registration script. I would like the script to check the database if the username already exists: $query = "select * from users where username='$username'"; $result = mysql_query($query); if ($result->num_rows>0) {echo 'That username is taken'; exit;} Unfortunately this does not seem to be working. When I submit a duplicate user, I get a MySQL error rather than getting "That username is taken" My guess is it has to do with: $result->num_rows>0) As my book is based on PHP 5 but PHP 4 is running on my server. Link to comment https://forums.phpfreaks.com/topic/63624-user-registration-script/ Share on other sites More sharing options...
phpknight Posted August 6, 2007 Share Posted August 6, 2007 Try this if (mysql_num_rows($result)>0) Link to comment https://forums.phpfreaks.com/topic/63624-user-registration-script/#findComment-317028 Share on other sites More sharing options...
avillanu Posted August 7, 2007 Author Share Posted August 7, 2007 Works thank you Link to comment https://forums.phpfreaks.com/topic/63624-user-registration-script/#findComment-317733 Share on other sites More sharing options...
phpknight Posted August 7, 2007 Share Posted August 7, 2007 No problem. Link to comment https://forums.phpfreaks.com/topic/63624-user-registration-script/#findComment-317772 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.