PHP Parse error: syntax error, unexpected $end?
Having an issue where I keep having this message thrown out at me...
Parse error: syntax error, unexpected $end in C:\xampp\htdocs\site\temp\info.php on line 38
I've had this a few times before and have always managed to spot the mistake, usually a missing bracket, however have spent ages trying to spot the mistake this time and can't see it anywhere. What's more puzzling is i've copied the code from elsewhere on my site and it seems to work from the original source and yet the structure seems the same.
If you could help i'd be grateful, code is as follows (line 38 is roughly where it checks through an array of allowed extensions) ....
<?php
include("config.php");
include("access.php");
$password = trim($_POST['password']);
$quote = trim($_POST['quote']);
$contactable = $_POST['select'];
$user = $_COOKIE['Username'];
$filename = $_FILES['uploadedfile']['name'];
$allowed_filetypes = array('jpg','gif','bmp','png');
$max_filesize = 55000;
$target_path = "images/uploads/";
// Checks all fields have been completed.
if (!trim($password) || !trim($quote)) {
header('Location: error.php?code=1');
exit();
}
else {
setcookie("Password", $password, 0);
$connect = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Ah Fuck - MySQL error!');
mysql_select_db($dbname) or die ('Ah Fuck - MySQL error!');
$query = mysql_query("UPDATE members SET password = '$password' WHERE username = '$username'");
$query = mysql_query("UPDATE members SET quote = '$quote' WHERE username = '$username'");
$query = mysql_query("UPDATE members SET message = '$contactable' WHERE username = '$username'");
if($filename!=''){
$filename = strtolower($filename);
$exts = split("[/\.]", $filename);
$n = count($exts)-1;
$exts = $exts[$n];
$username2 = $username.".";
$username2 = $username2.$exts;
if(!in_array($exts,$allowed_filetypes)){
header('Location: error.php?code=8');
exit();
}
// It's all good so check file size...
$target_path = $target_path . $username2;
$filesize = $_FILES['uploadedfile']['size'];
if ($filesize > 50000 || $filesize==0){
header('Location: error.php?code=9');
exit();
}
// If good then upload image and create new member!
move_uploaded_file($_FILES['uploadedfile']['tmp_name'],$target_path);
$query = mysql_query("UPDATE members SET type = '$exts' WHERE username = '$username'");
}
}
header('Location: info.php?code=2');
?>
if(!in_array($exts,$allowed_filetypes)){
header('Location: error.php?code=8');
exit();
}
If I comment out the below line then the page works fine and there's no error message...
header('Location: info.php?code=2');
Not sure how (this being the bottom line) is affecting line 38 with the error message.
|