I am trying to have a script so I can add a user to my db so people can view the website ect. The script works, add the name and password and the details are added to the db. One problem is i have an error message. Line 23 is if(mysql_num_rows($result) == 0){ PHP: The full script is <? session_start() ?> <HTML> <HEAD> <TITLE>Register</TITLE> </HEAD> <BODY> <H2>Register a new user</H2> <img src="/images/logo.gif" align="left" /><br /> <? // check to see if these two variables have been passed from // the HTML form at the foot of this script (which calls this page again) if ($user && $pass) { // connect to database and select the 'userlist' database $db = mysql_connect ("localhost", "?", "?"); mysql_select_db('?',$db); // check to see if username is already on the database $result = mysql_query ("SELECT * FROM Users WHERE Name = '".$User."'"); if(mysql_num_rows($result) == 0){ // if it's not, add the new details to the database $result = mysql_query ("INSERT INTO users (name, password) VALUES ('".$user."', PASSWORD('".$pass."'))"); if ($result) { // if successful, log in the user and show a welcome message // then exit the script echo "The details have been added to the database for ".$user."<BR><BR>"; echo "<A HREF='register.php'>Click here to add another user.</A><BR><BR>"; echo "<A HREF='index.php'>Click here view the uploaded files again.</A>"; exit; } else { // if the details could not be added for some reason, // show an error message echo "<font color='#FF0000'>Sorry, there has been a technical hitch. We cannot enter your details.</font>"; exit; } } else { // if the details were already on the database, let the user try again echo "<font color='#FF0000'>Sorry, that username has been taken. Please try another.</font><BR>"; } } else if ($user || $pass) { // if the user has filled in one field but not the other, // throw up this error echo "<font color='#FF0000'>Please fill in both fields.</font>"; } // show HTML form as follows ?> To add a new user, please complete the details below.<br><br> enter the username and the password. Straight Away, the username and password would be active. <FORM METHOD=POST ACTION="register.php"> Please enter a username: <INPUT NAME="user" TYPE=TEXT MAXLENGTH=20 SIZE=20>(20) <BR> Please enter a password: <INPUT NAME="pass" TYPE=PASSWORD MAXLENGTH=10 SIZE=10>(10) <BR> <INPUT TYPE=SUBMIT VALUE="Register"> </FORM> <br><br> </BODY> </HTML> PHP: What is wrong with that line.
Thank you The script mentioned the table name Users does not exist, of course, the table name is users.
Ahh beat me to it. I was gonna say that capital U probably was your problem. I always check for errors like this: $result = mysql_query ("SELECT * FROM Users WHERE Name = '".$User."'") or exit(mysql_error()); PHP: