The Sea King Posted March 17, 2008 Share Posted March 17, 2008 if (mysql_query("SELECT Username FROM Members WHERE Username = $username" LIMIT 1")){die("$username is taken");} Link to comment Share on other sites More sharing options...
Synook Posted March 17, 2008 Share Posted March 17, 2008 You need to use mysql_num_rows(), as that query will always return true (unless there is an error), even if it has zero rows. if (mysql_num_rows(mysql_query("SELECT Username FROM Members WHERE Username = $username" LIMIT 1")) == 1) { die("$username is taken");} Link to comment Share on other sites More sharing options...
The Sea King Posted March 17, 2008 Author Share Posted March 17, 2008 it keeps saying:Parse error: syntax error, unexpected T_STRING in /register.php on line 20 <html><body><?php$username=$_POST['username'];$email=$_POST['email'];$password=$_POST['password'];$sql= mysql_connect("HIDDEN","HIDDEN","HIDDEN");$database=mysql_select_db("HIDDEN");if (!$sql){die('Could not connect: ' . mysql_error());}if (!$database){die ("Could not select db: " . mysql_error());}// Testing if (mysql_num_rows(mysql_query("SELECT Username FROM Members WHERE Username = $username" LIMIT 1")) == 1){die("$username is taken");}if (!mysql_query("INSERT INTO Member (Username, Password, Email, Folder)VALUES ('$username','$password','$email','http://thelostwaters.com/upload/$username/')")){die("Query failed: " . mysql_error());}mysql_close($sql);echo "You're registered as:<br>$username<br>Password<br>$password<br>Email:<br>$email<br>Your Folder:<br>http://thelostwaters.com/upload/$username";?></body></html> Link to comment Share on other sites More sharing options...
designationlocutus Posted March 18, 2008 Share Posted March 18, 2008 it keeps saying:Parse error: syntax error, unexpected T_STRING in /register.php on line 20You have an extra quote before LIMIT.Might be good to place a bit of SQL Injection protection routines in there too. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.