The Sea King 0 Posted March 17, 2008 Report Share Posted March 17, 2008 if (mysql_query("SELECT Username FROM Members WHERE Username = $username" LIMIT 1")){die("$username is taken");} Quote Link to post Share on other sites
Synook 47 Posted March 17, 2008 Report 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");} Quote Link to post Share on other sites
The Sea King 0 Posted March 17, 2008 Author Report 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> Quote Link to post Share on other sites
designationlocutus 0 Posted March 18, 2008 Report 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. Quote Link to post Share on other sites
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.