Anybody here good with php? Well, I get a Parse error: parse error, unexpected T_STRING in /www/1111mb.com/u/g/n/ugnetwork/htdocs/Register.php on line 46 Error when I try to acsess my Registration page. Heres the Code. Code: <html> <title>UGN Registration</title> <head></head> <body> <center> <?php // Connects to your Database mysql_connect("localhost", "Hidden", "Hidden") or die(mysql_error()); mysql_select_db("hidden") or die(mysql_error()); //This code runs if the form has been submitted if (isset($_POST['submit'])) { //This makes sure they did not leave any fields blank if (!$_POST['username'] | !$_POST['pass'] | !$_POST['pass2'] ) { die('You did not complete all of the required fields'); } // checks if the username is in use if (!get_magic_quotes_gpc()) { $_POST['username'] = addslashes($_POST['username']); } $usercheck = $_POST['username']; $check = mysql_query("SELECT username FROM users WHERE username = '$usercheck'") or die(mysql_error()); $check2 = mysql_num_rows($check); //if the name exists it gives an error if ($check2 != 0) { die('Sorry, the username '.$_POST['username'].' is already in use.'); } // this makes sure both passwords entered match if ($_POST['pass'] != $_POST['pass2']) { die('Your passwords did not match. '); } // here we encrypt the password and add slashes if needed $_POST['pass'] = md5($_POST['pass']); if (!get_magic_quotes_gpc()) { $_POST['pass'] = addslashes($_POST['pass']); $_POST['username'] = addslashes($_POST['username']); } // now we insert it into the database $insert = "INSERT INTO users (username, password) VALUES ('".$_POST['username']."', '".$_POST['pass']."')"; $add_member = mysql_query($insert); ?> <h1>Registered</h1> Thank you, you have registered - you may now login</a>.</p> <?php } else { ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <table border="0"> <tr><td>Username:</td><td> <input type="text" name="username" maxlength="60"> </td></tr> <tr><td>Password:</td><td> <input type="password" name="pass" maxlength="10"> </td></tr> <tr><td>Confirm Password:</td><td> <input type="password" name="pass2" maxlength="10"> </td></tr> <tr><th colspan=2><input type="submit" name="submit" value="Register"></th></tr> </table> </form> <?php } ?> </center> </body> </html> On the 46th code line, this is written Code: VALUES ('".$_POST['username']."', '".$_POST['pass']."')"; I cant really spot anything wrong with it, since im pretty new to php anybody help? Im sooo close to getting my game up and working.... N the most annoying thing is its probally just a miss placed letter or a missing ; lol
Were u editing the register.php? What was the original and edited version Check the names of databases and stuff to make sure its correct OR Just triple-check that what u supposed to edit is the same thing for what you are trying to do - Its usually something minor hmm ... *thinks* DarkStar
I was testing the Registration page, It doesnt load, just shows the parse error. Its a completly from new script, so there was no verson before that worked, This is closest i've got to the registration working lol...
this is line 46 VALUES ('".$_POST['username']."', '".$_POST['pass']."')"; i know no php at all but try changing it this VALUES ('.$_POST['username'].', '.$_POST['pass'].'); or this VALUES ('".$_POST['username']."', '".$_POST['pass']."'); i just messed around with the quotes because on line 30 die('Sorry, the username '.$_POST['username'].' is already in use.'); it doesnt have the quotes
ds, the error deals with what PHP thinks is a String, not the databases, which is where the t_string comes into play. Uhh dude, look at the whole thing: Code: // now we insert it into the database $insert = "INSERT INTO users (username, password) VALUES ('".$_POST['username']."', '".$_POST['pass']."')"; $add_member = mysql_query($insert); You must take this part out from the // comment. Code: $insert = "INSERT INTO users //.. So now the three lines are: Code: // now we insert it into the database $insert = "INSERT INTO users (username, password) VALUES ('".$_POST['username']."', '".$_POST['pass']."')"; $add_member = mysql_query($insert); (who ever made that (i dunno if it was you) should have caugh that in debugging. On another note, try and keep your Naming Conventions (whether it was you or somebody else) the same throughout the entire project. I notice that one Input Name is spelled out entirely (username), but one is abbreviated (pass); try to fix that so both are the same. Either make both abbreviated or make both spelled out, it makes debugging later on much easier (also easier when you want to add stuff to the script.)