Jump to content

Is this alright?


The Sea King

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...