jamesxg1 Posted May 20, 2009 Share Posted May 20, 2009 <?php session_start(); include 'Utilitys/Connection.php'; include 'Utilitys/Functions.php'; if (isset($_POST['submit'])) { $role = "1"; $id = mt_rand(0, 9999999999); $time = date("F j, Y, g:i a"); $signup = date("F j, Y, g:i a"); $username = protect($_POST['Username']); $password = protect(md5($_POST['Password'])); $firstname = protect($_POST['FirstName']); $lastname = protect($_POST['LastName']); $email = protect($_POST['Email']); if (isset($role) && isset($id) && isset($time) && isset($signup) && isset($username) && isset($password) && isset($firstname) && isset($lastname) && isset($email)) { $save = "SELECT * FROM `users` WHERE username LIKE '$username'" or die (mysql_error()); $result = mysql_query($save); if (mysql_num_row($result) > 0) { $flag = "INSERT INTO `users` ('id', 'username', 'password', 'firstname', 'lastname', 'email', 'role', 'time', 'signup', 'gender') VALUES('$id', '$username', '$password', '$firstname', '$lastname', '$email', '$role', '$time', '$signup')" or die (mysql_error()); $run = mysql_query($flag); print "<p align="center">Welcome $username,<br>You Have Now Been Register, Please <a href='Login.php'>Login</a><br>Many Thanks,<br>Admin.</p>"; else { print "<p align="center">Please Fill All Required Fields.</p>"; } else { print "<p align="center">Sorry But That Username ($username) Already Exist's, <br> Please Try Again.</p>"; } ?> i have this error. Parse error: parse error in C:\xampp\htdocs\social\SaveUser.php on line 32 i cant for the love of god see whats wrong with it :S Quote Link to comment https://forums.phpfreaks.com/topic/158902-parse-error-help/ Share on other sites More sharing options...
Mark Baker Posted May 20, 2009 Share Posted May 20, 2009 Look at the way print "<p align="center"> is highlighted, then escape your quotes Quote Link to comment https://forums.phpfreaks.com/topic/158902-parse-error-help/#findComment-838033 Share on other sites More sharing options...
trq Posted May 20, 2009 Share Posted May 20, 2009 Your using double quotes within a double quoted string. Ps: Its not the only line with this error. Quote Link to comment https://forums.phpfreaks.com/topic/158902-parse-error-help/#findComment-838034 Share on other sites More sharing options...
jamesxg1 Posted May 20, 2009 Author Share Posted May 20, 2009 Look at the way print "<p align="center"> is highlighted, then escape your quotes oh christ i cant belive i didnt notice that thanks dude. Quote Link to comment https://forums.phpfreaks.com/topic/158902-parse-error-help/#findComment-838036 Share on other sites More sharing options...
jamesxg1 Posted May 20, 2009 Author Share Posted May 20, 2009 <?php session_start(); include 'Utilitys/Connection.php'; include 'Utilitys/Functions.php'; if (isset($_POST['submit'])) { $role = "1"; $id = mt_rand(0, 9999999999); $time = date("F j, Y, g:i a"); $signup = date("F j, Y, g:i a"); $username = protect($_POST['Username']); $password = protect(md5($_POST['Password'])); $firstname = protect($_POST['FirstName']); $lastname = protect($_POST['LastName']); $email = protect($_POST['Email']); if (isset($role) && isset($id) && isset($time) && isset($signup) && isset($username) && isset($password) && isset($firstname) && isset($lastname) && isset($email)) { $save = "SELECT * FROM `users` WHERE username LIKE '$username'" or die (mysql_error()); $result = mysql_query($save); if (mysql_num_row($result) > 0) { $flag = "INSERT INTO `users` ('id', 'username', 'password', 'firstname', 'lastname', 'email', 'role', 'time', 'signup', 'gender') VALUES('$id', '$username', '$password', '$firstname', '$lastname', '$email', '$role', '$time', '$signup')" or die (mysql_error()); $run = mysql_query($flag); print "<p align='center'>Welcome $username,<br>You Have Now Been Register, Please <a href='Login.php'>Login</a><br>Many Thanks,<br>Admin.</p>"; else { print "<p align='center'>Please Fill All Required Fields.</p>"; } else { print "<p align='center'>Sorry But That Username ($username) Already Exist's, <br> Please Try Again.</p>"; } ?> changed ^^ this error is being displayed Parse error: parse error in C:\xampp\htdocs\social\SaveUser.php on line 32 Quote Link to comment https://forums.phpfreaks.com/topic/158902-parse-error-help/#findComment-838037 Share on other sites More sharing options...
DarkSuperHero Posted May 20, 2009 Share Posted May 20, 2009 <?php session_start(); include 'Utilitys/Connection.php'; include 'Utilitys/Functions.php'; if (isset($_POST['submit'])) { $role = "1"; $id = mt_rand(0, 9999999999); $time = date("F j, Y, g:i a"); $signup = date("F j, Y, g:i a"); $username = protect($_POST['Username']); $password = protect(md5($_POST['Password'])); $firstname = protect($_POST['FirstName']); $lastname = protect($_POST['LastName']); $email = protect($_POST['Email']); if (isset($role) && isset($id) && isset($time) && isset($signup) && isset($username) && isset($password) && isset($firstname) && isset($lastname) && isset($email)) { $save = "SELECT * FROM `users` WHERE username LIKE '$username'" or die (mysql_error()); $result = mysql_query($save); if (mysql_num_row($result) > 0) { $flag = "INSERT INTO `users` ('id', 'username', 'password', 'firstname', 'lastname', 'email', 'role', 'time', 'signup', 'gender') VALUES('$id', '$username', '$password', '$firstname', '$lastname', '$email', '$role', '$time', '$signup')" or die (mysql_error()); $run = mysql_query($flag); print "<p align='center'>Welcome $username,<br>You Have Now Been Register, Please <a href='Login.php'>Login</a><br>Many Thanks,<br>Admin.</p>"; } //missing closing inner if brace... else { print "<p align='center'>Please Fill All Required Fields.</p>"; } } //missing outer if end brace... else { print "<p align='center'>Sorry But That Username ($username) Already Exist's, <br> Please Try Again.</p>"; } ?> See code for adjustment & comments Quote Link to comment https://forums.phpfreaks.com/topic/158902-parse-error-help/#findComment-838040 Share on other sites More sharing options...
trq Posted May 20, 2009 Share Posted May 20, 2009 If you indent your code you might see these simple errors. Quote Link to comment https://forums.phpfreaks.com/topic/158902-parse-error-help/#findComment-838044 Share on other sites More sharing options...
jamesxg1 Posted May 20, 2009 Author Share Posted May 20, 2009 If you indent your code you might see these simple errors. what do you mean ? Quote Link to comment https://forums.phpfreaks.com/topic/158902-parse-error-help/#findComment-838073 Share on other sites More sharing options...
jamesxg1 Posted May 20, 2009 Author Share Posted May 20, 2009 <?php session_start(); include 'Utilitys/Connection.php'; include 'Utilitys/Functions.php'; if (isset($_POST['submit'])) { $role = "1"; $id = mt_rand(0, 9999999999); $time = date("F j, Y, g:i a"); $signup = date("F j, Y, g:i a"); $username = protect($_POST['Username']); $password = protect(md5($_POST['Password'])); $firstname = protect($_POST['FirstName']); $lastname = protect($_POST['LastName']); $email = protect($_POST['Email']); if (isset($role) && isset($id) && isset($time) && isset($signup) && isset($username) && isset($password) && isset($firstname) && isset($lastname) && isset($email)) { $save = "SELECT * FROM `users` WHERE username LIKE '$username'" or die (mysql_error()); $result = mysql_query($save); if (mysql_num_row($result) > 0) { $flag = "INSERT INTO `users` ('id', 'username', 'password', 'firstname', 'lastname', 'email', 'role', 'time', 'signup', 'gender') VALUES('$id', '$username', '$password', '$firstname', '$lastname', '$email', '$role', '$time', '$signup')" or die (mysql_error()); $run = mysql_query($flag); print "<p align='center'>Welcome $username,<br>You Have Now Been Register, Please <a href='Login.php'>Login</a><br>Many Thanks,<br>Admin.</p>"; } //missing closing inner if brace... else { print "<p align='center'>Please Fill All Required Fields.</p>"; } } //missing outer if end brace... else { print "<p align='center'>Sorry But That Username ($username) Already Exist's, <br> Please Try Again.</p>"; } ?> See code for adjustment & comments cheers for your help mat but unfortunetly it didnt work Quote Link to comment https://forums.phpfreaks.com/topic/158902-parse-error-help/#findComment-838076 Share on other sites More sharing options...
Dathremar Posted May 20, 2009 Share Posted May 20, 2009 Use tab to indent your code, so You know what chunk of code belongs where. It will make Your code much easier to read and to follow open and closed brackets. Quote Link to comment https://forums.phpfreaks.com/topic/158902-parse-error-help/#findComment-838077 Share on other sites More sharing options...
jamesxg1 Posted May 20, 2009 Author Share Posted May 20, 2009 oh i see lol, i make all my code in notepad lol Quote Link to comment https://forums.phpfreaks.com/topic/158902-parse-error-help/#findComment-838082 Share on other sites More sharing options...
Dathremar Posted May 20, 2009 Share Posted May 20, 2009 <?php session_start(); include 'Utilitys/Connection.php'; include 'Utilitys/Functions.php'; if (isset($_POST['submit'])) { $role = "1"; $id = mt_rand(0, 9999999999); $time = date("F j, Y, g:i a"); $signup = date("F j, Y, g:i a"); $username = protect($_POST['Username']); $password = protect(md5($_POST['Password'])); $firstname = protect($_POST['FirstName']); $lastname = protect($_POST['LastName']); $email = protect($_POST['Email']); if (isset($role) && isset($id) && isset($time) && isset($signup) && isset($username) && isset($password) && isset($firstname) && isset($lastname) && isset($email)) { $save = "SELECT * FROM `users` WHERE username LIKE '$username'" or die (mysql_error()); $result = mysql_query($save); if (mysql_num_row($result) > 0) { $flag = "INSERT INTO `users` ('id', 'username', 'password', 'firstname', 'lastname', 'email', 'role', 'time', 'signup', 'gender') VALUES('$id', '$username', '$password', '$firstname', '$lastname', '$email', '$role', '$time', '$signup')" or die (mysql_error()); $run = mysql_query($flag); print "<p align='center'>Welcome $username,<br>You Have Now Been Register, Please <a href='Login.php'>Login</a><br>Many Thanks,<br>Admin.</p>"; } else { print "<p align='center'>Please Fill All Required Fields.</p>"; } } else { print "<p align='center'>Sorry But That Username ($username) Already Exist's, <br> Please Try Again.</p>"; } // another bracket missing } ?> Edited to put the code in php tags :/ There was 1 more missing bracket at the end Quote Link to comment https://forums.phpfreaks.com/topic/158902-parse-error-help/#findComment-838085 Share on other sites More sharing options...
jamesxg1 Posted May 20, 2009 Author Share Posted May 20, 2009 <?php session_start(); include 'Utilitys/Connection.php'; include 'Utilitys/Functions.php'; if (isset($_POST['submit'])) { $role = "1"; $id = mt_rand(0, 9999999999); $time = date("F j, Y, g:i a"); $signup = date("F j, Y, g:i a"); $username = protect($_POST['Username']); $password = protect(md5($_POST['Password'])); $firstname = protect($_POST['FirstName']); $lastname = protect($_POST['LastName']); $email = protect($_POST['Email']); if (isset($role) && isset($id) && isset($time) && isset($signup) && isset($username) && isset($password) && isset($firstname) && isset($lastname) && isset($email)) { $save = "SELECT * FROM `users` WHERE username LIKE '$username'" or die (mysql_error()); $result = mysql_query($save); if (mysql_num_row($result) > 0) { $flag = "INSERT INTO `users` ('id', 'username', 'password', 'firstname', 'lastname', 'email', 'role', 'time', 'signup', 'gender') VALUES('$id', '$username', '$password', '$firstname', '$lastname', '$email', '$role', '$time', '$signup')" or die (mysql_error()); $run = mysql_query($flag); print "<p align='center'>Welcome $username,<br>You Have Now Been Register, Please <a href='Login.php'>Login</a><br>Many Thanks,<br>Admin.</p>"; } else { print "<p align='center'>Please Fill All Required Fields.</p>"; } } else { print "<p align='center'>Sorry But That Username ($username) Already Exist's, <br> Please Try Again.</p>"; } // another bracket missing } ?> Edited to put the code in php tags :/ There was 1 more missing bracket at the end Fatal error: Call to undefined function mysql_num_row() in C:\xampp\htdocs\social\SaveUser.php on line 39 Quote Link to comment https://forums.phpfreaks.com/topic/158902-parse-error-help/#findComment-838087 Share on other sites More sharing options...
Dathremar Posted May 20, 2009 Share Posted May 20, 2009 It should be mysql_num_rows() Quote Link to comment https://forums.phpfreaks.com/topic/158902-parse-error-help/#findComment-838091 Share on other sites More sharing options...
jamesxg1 Posted May 20, 2009 Author Share Posted May 20, 2009 cheers dude , done all working except one thing =/ it isnt inserting into DB :S Quote Link to comment https://forums.phpfreaks.com/topic/158902-parse-error-help/#findComment-838095 Share on other sites More sharing options...
Ken2k7 Posted May 20, 2009 Share Posted May 20, 2009 1. You don't need to protect a md5 hash value. A md5-ed value doesn't do any harm to the DB. 2. Remove all those quotes around column names in your INSERT. $flag = "INSERT INTO `users` ('id', 'username', 'password', 'firstname', 'lastname', 'email', 'role', 'time', 'signup', 'gender') VALUES('$id', '$username', '$password', '$firstname', '$lastname', '$email', '$role', '$time', '$signup')" or die (mysql_error()); See where you have single quotes around id, username, password etc? Remove them. Quote Link to comment https://forums.phpfreaks.com/topic/158902-parse-error-help/#findComment-838109 Share on other sites More sharing options...
jamesxg1 Posted May 20, 2009 Author Share Posted May 20, 2009 have i got any of the else's wrong ? <?php session_start(); include 'Utilitys/Connection.php'; include 'Utilitys/Functions.php'; $role = "1"; $id = mt_rand(0, 9999999999); $time = date("F j, Y, g:i a"); $signup = date("F j, Y, g:i a"); $username = protect($_POST['Username']); $password = md5($_POST['Password']); $firstname = protect($_POST['FirstName']); $lastname = protect($_POST['LastName']); $email = protect($_POST['Email']); if (isset($_POST['submit'])) { if (isset($username) && isset($password) && isset($firstname) && isset($lastname) && isset($email)) { $save = "SELECT * FROM `users` WHERE username LIKE '$username'" or die (mysql_error()); $result = mysql_query($save); if (mysql_num_rows($result) > 0) { $flag = "INSERT INTO `users` (id, username, password, firstname, lastname, email, role, time, signup, gender) VALUES('$id', '$username', '$password', '$firstname', '$lastname', '$email', '$role', '$time', '$signup')" or die (mysql_error()); $run = mysql_query($flag); print "<p align='center'>Welcome $username,<br>You Have Now Been Register, Please <a href='Login.php'>Login</a><br>Many Thanks,<br>Admin.</p>"; } else { print "<p align='center'>Please Fill All Required Fields.</p>"; } } else { print "<p align='center'>Sorry But That Username ($username) Already Exist's, <br> Please Try Again.</p>"; } } ?> because i fill in the whole form to test and when i post it shows the error *Please Fill All Required Fields.* Quote Link to comment https://forums.phpfreaks.com/topic/158902-parse-error-help/#findComment-838126 Share on other sites More sharing options...
Ken2k7 Posted May 20, 2009 Share Posted May 20, 2009 1. Run password through protect before md5. 2. Your INSERT query is missing the gender field. 3. Remove the or die line from $save. You're setting a string. It shouldn't fail. Move it to the $result = mysql_query($save) line. This goes the same for your $flag line. Quote Link to comment https://forums.phpfreaks.com/topic/158902-parse-error-help/#findComment-838129 Share on other sites More sharing options...
jamesxg1 Posted May 20, 2009 Author Share Posted May 20, 2009 1. Run password through protect before md5. 2. Your INSERT query is missing the gender field. 3. Remove the or die line from $save. You're setting a string. It shouldn't fail. Move it to the $result = mysql_query($save) line. This goes the same for your $flag line. <?php session_start(); include 'Utilitys/Connection.php'; include 'Utilitys/Functions.php'; $role = "1"; $id = mt_rand(0, 9999999999); $time = date("F j, Y, g:i a"); $signup = date("F j, Y, g:i a"); $username = protect($_POST['Username']); $password = protect($_POST['Password']); $password = md5($_POST['Password']); $firstname = protect($_POST['FirstName']); $lastname = protect($_POST['LastName']); $email = protect($_POST['Email']); if (isset($_POST['submit'])) { if (isset($username) && isset($password) && isset($firstname) && isset($lastname) && isset($email)) { $save = "SELECT * FROM `users` WHERE username LIKE '$username'" or die (mysql_error()); $result = mysql_query($save); if (mysql_num_rows($result) > 0) { $flag = "INSERT INTO `users` (id, username, password, firstname, lastname, email, role, time, signup, gender) VALUES('$id', '$username', '$password', '$firstname', '$lastname', '$email', '$role', '$time', '$signup', 'M')" or die (mysql_error()); $run = mysql_query($flag); print "<p align='center'>Welcome $username,<br>You Have Now Been Register, Please <a href='Login.php'>Login</a><br>Many Thanks,<br>Admin.</p>"; } else { print "<p align='center'>Please Fill All Required Fields.</p>"; } } else { print "<p align='center'>Sorry But That Username ($username) Already Exist's, <br> Please Try Again.</p>"; } } ?> done , but i still have to what i belive a else problem. Quote Link to comment https://forums.phpfreaks.com/topic/158902-parse-error-help/#findComment-838142 Share on other sites More sharing options...
BobcatM Posted May 20, 2009 Share Posted May 20, 2009 'M')" Why do you have this? Quote Link to comment https://forums.phpfreaks.com/topic/158902-parse-error-help/#findComment-838153 Share on other sites More sharing options...
Ken2k7 Posted May 20, 2009 Share Posted May 20, 2009 1. Run password through protect before md5. 2. Your INSERT query is missing the gender field. 3. Remove the or die line from $save. You're setting a string. It shouldn't fail. Move it to the $result = mysql_query($save) line. This goes the same for your $flag line. <?php session_start(); include 'Utilitys/Connection.php'; include 'Utilitys/Functions.php'; $role = "1"; $id = mt_rand(0, 9999999999); $time = date("F j, Y, g:i a"); $signup = date("F j, Y, g:i a"); $username = protect($_POST['Username']); $password = protect($_POST['Password']); $password = md5($_POST['Password']); $firstname = protect($_POST['FirstName']); $lastname = protect($_POST['LastName']); $email = protect($_POST['Email']); if (isset($_POST['submit'])) { if (isset($username) && isset($password) && isset($firstname) && isset($lastname) && isset($email)) { $save = "SELECT * FROM `users` WHERE username LIKE '$username'" or die (mysql_error()); $result = mysql_query($save); if (mysql_num_rows($result) > 0) { $flag = "INSERT INTO `users` (id, username, password, firstname, lastname, email, role, time, signup, gender) VALUES('$id', '$username', '$password', '$firstname', '$lastname', '$email', '$role', '$time', '$signup', 'M')" or die (mysql_error()); $run = mysql_query($flag); print "<p align='center'>Welcome $username,<br>You Have Now Been Register, Please <a href='Login.php'>Login</a><br>Many Thanks,<br>Admin.</p>"; } else { print "<p align='center'>Please Fill All Required Fields.</p>"; } } else { print "<p align='center'>Sorry But That Username ($username) Already Exist's, <br> Please Try Again.</p>"; } } ?> done , but i still have to what i belive a else problem. Not done. Read 3 again! Quote Link to comment https://forums.phpfreaks.com/topic/158902-parse-error-help/#findComment-838162 Share on other sites More sharing options...
jamesxg1 Posted May 20, 2009 Author Share Posted May 20, 2009 'M')" Why do you have this? stands for male. Quote Link to comment https://forums.phpfreaks.com/topic/158902-parse-error-help/#findComment-838163 Share on other sites More sharing options...
jamesxg1 Posted May 20, 2009 Author Share Posted May 20, 2009 <?php session_start(); include 'Utilitys/Connection.php'; include 'Utilitys/Functions.php'; $role = "1"; $id = mt_rand(0, 9999999999); $time = date("F j, Y, g:i a"); $signup = date("F j, Y, g:i a"); $username = protect($_POST['Username']); $password = protect($_POST['Password']); $password = md5($_POST['Password']); $firstname = protect($_POST['FirstName']); $lastname = protect($_POST['LastName']); $email = protect($_POST['Email']); if (isset($_POST['submit'])) { if (isset($username) && isset($password) && isset($firstname) && isset($lastname) && isset($email)) { $save = "SELECT * FROM `users` WHERE username LIKE '$username'"; $result = mysql_query($save); if (mysql_num_rows($result) > 0) { $flag = "INSERT INTO `users` (id, username, password, firstname, lastname, email, role, time, signup, gender) VALUES('$id', '$username', '$password', '$firstname', '$lastname', '$email', '$role', '$time', '$signup', 'M')" or die (mysql_error()); $run = mysql_query($flag); print "<p align='center'>Welcome $username,<br>You Have Now Been Register, Please <a href='Login.php'>Login</a><br>Many Thanks,<br>Admin.</p>"; } else { print "<p align='center'>Please Fill All Required Fields.</p>"; } } else { print "<p align='center'>Sorry But That Username ($username) Already Exist's, <br> Please Try Again.</p>"; } } ?> done and still getting the *Please Fill All Required Fields.* Quote Link to comment https://forums.phpfreaks.com/topic/158902-parse-error-help/#findComment-838167 Share on other sites More sharing options...
Ken2k7 Posted May 20, 2009 Share Posted May 20, 2009 I must have to write in big letter. Read #3 again. Also, does $result return any data. The only way you're getting that message is if $result returns nothing. Quote Link to comment https://forums.phpfreaks.com/topic/158902-parse-error-help/#findComment-838173 Share on other sites More sharing options...
jamesxg1 Posted May 20, 2009 Author Share Posted May 20, 2009 I must have to write in big letter. Read #3 again. Also, does $result return any data. The only way you're getting that message is if $result returns nothing. i completely removed it it wasnt worth the work, thanyou everyone for your help, take care all, and thanks for your time. Quote Link to comment https://forums.phpfreaks.com/topic/158902-parse-error-help/#findComment-838178 Share on other sites More sharing options...
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.