Jump to content

Unexpected $end?


mjnmixael

Recommended Posts

I'm getting this error

 

Parse error: syntax error, unexpected $end in /home/content/m/j/n/mjnmixael/html/subscribers/changepass.php on line 144

 

with this script.

 

// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

// Set values
$newpassword1=0;
$firstname=0;
$lastname=0;
$email=0;
$complete=0;

// Get values from form
$password=$_POST['password'];
$newpassword1=$_POST['newpassword'];
$newpassword2=$_POST['newpassword2'];
$firstname=$_POST['firstname'];
$lasname=$_POST['lastname'];
$email=$_POST['email'];
$secpassword=md5($_POST['newpassword']);
$userid=$_COOKIE['userid'];

// Check password confirmation
if($newpassword1 > $newpassword2){
$nomatch = 'nomatch';
setcookie("regerrorp", $nomatch, 0, "/", '.timingishstudios.com');
unset($password);
unset($password2);
header("location:http://www.timingishstudios.com/subscribers/changepassword.php");
exit();
}

// Authenticate
$sql="SELECT * FROM $tbl_name WHERE user_pass='$secpassword'";
$result=mysql_query($sql);

// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row

if($count==1){

// Make changes
if ($newpassword1 > 0){
$sql="UPDATE $tbl_name SET user_pass = '$secpassword' WHERE ID='$userid'";
$result=mysql_query($sql);
}
if($result){
$complete++;
}
else {
header("location:recovererror.php");
}
if ($email > 0){
$sql="UPDATE $tbl_name SET user_email = '$email' WHERE ID='$userid'";
$result=mysql_query($sql);
}
if($result){
$complete++;
}
else {
header("location:recovererror.php");
}
if ($firstname > 0){
$sql="UPDATE $tbl_name2 SET meta_value = '$firstname' WHERE user_id='$userid' AND meta_key='first_name'";
$result=mysql_query($sql);
$sql="UPDATE $tbl_name2 SET meta_value = '$firstname' WHERE user_id='$userid' AND meta_key='nickname'";
$result=mysql_query($sql);
}
if($result){
$complete++;
}
else {
header("location:recovererror.php");
}
if ($lastname > 0){
$sql="UPDATE $tbl_name2 SET meta_value = '$lastname' WHERE user_id='$userid' AND meta_key='last_name'";
$result=mysql_query($sql);
}
if($result){
$complete++;
}
else {
header("location:recovererror.php");
}

// If sucsessful..
if($complete > 0){	
$sql="SELECT user_email FROM $tbl_name WHERE ID='$userid'";
$result=mysql_query($sql);
$row = mysql_fetch_assoc($result);
$email=$row['user_email'];
$sql="SELECT user_login FROM $tbl_name WHERE ID='$userid'";
$result=mysql_query($sql);
$row = mysql_fetch_assoc($result);
$username=$row['user_login'];
$sql="SELECT meta_value FROM $tbl_name2 WHERE user_id='$userid' AND meta_key='first_name'";
$result=mysql_query($sql);
$row = mysql_fetch_assoc($result);
$firstname=$row['meta_value'];
$sql="SELECT meta_value FROM $tbl_name2 WHERE user_id='$userid' AND meta_key='last_name'";
$result=mysql_query($sql);
$row = mysql_fetch_assoc($result);
$lastname=$row['meta_value'];
// send e-mail to ...
$to="$email";

// Your subject
$subject="Timingishstudios.com Account Info Changed";

// From
$header="from: Timingishstudios.com <donotreply>";

// Your message
$messages= "Your account information has been changed. \r\n";
$messages.="Email: $email \r\n";
$messages.="Username: $username \r\n";
$messages.="Password: $password \r\n";
$messages.="First Name: $firstname \r\n";
$messages.="Last Name: $lastname \r\n";
$messages.="The TiS Team. \r\n";

// send email
$sentmail = mail($to,$subject,$messages,$header);

// Redirect
header("location:changed.php");
}

else {
header("location:recovererror.php");
}

// close connection
mysql_close();
?>

 

I'm new to PHP and MYSQL. I realize there are probably a lot of redundancies in this script. I'm unfamiliar with this error and can't seem to figure it out. Any help?

Link to comment
https://forums.phpfreaks.com/topic/182305-unexpected-end/
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.