Jump to content

parse error help


jamesxg1

Recommended Posts

<?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

Link to comment
https://forums.phpfreaks.com/topic/158902-parse-error-help/
Share on other sites

<?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

 

Link to comment
https://forums.phpfreaks.com/topic/158902-parse-error-help/#findComment-838037
Share on other sites

<?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

Link to comment
https://forums.phpfreaks.com/topic/158902-parse-error-help/#findComment-838040
Share on other sites

<?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 :(

Link to comment
https://forums.phpfreaks.com/topic/158902-parse-error-help/#findComment-838076
Share on other sites

<?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

Link to comment
https://forums.phpfreaks.com/topic/158902-parse-error-help/#findComment-838085
Share on other sites

<?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

 

Link to comment
https://forums.phpfreaks.com/topic/158902-parse-error-help/#findComment-838087
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/158902-parse-error-help/#findComment-838109
Share on other sites

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.*

 

Link to comment
https://forums.phpfreaks.com/topic/158902-parse-error-help/#findComment-838126
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/158902-parse-error-help/#findComment-838142
Share on other sites

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!

Link to comment
https://forums.phpfreaks.com/topic/158902-parse-error-help/#findComment-838162
Share on other sites

<?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.*

Link to comment
https://forums.phpfreaks.com/topic/158902-parse-error-help/#findComment-838167
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/158902-parse-error-help/#findComment-838178
Share on other sites

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.