Forum Moderators: coopster

Message Too Old, No Replies

Parse error: syntax error, unexpected T IF

         

lindaonline15

4:28 pm on Sep 4, 2008 (gmt 0)

10+ Year Member



hi all,

I'm trying to make an upload page, but i get this error:
Parse error: syntax error, unexpected T_IF in C:\wamp\www\upload.php on line 36

line 36 is:

36 if (!$result) {
37 echo "Error uploading file";
38 exit;
39 }

what can be the problem here? why im getting this error?

lindaonline15

4:29 pm on Sep 4, 2008 (gmt 0)

10+ Year Member



i think you might need the full code as well, since i've seen the error always is related to far behind it, so this is the full code:

<html>
<head>
<title>upload</title></head>
<body>

<?php

include_once "connection.php";

$uploadDir = 'C:/wamp/www/uploads/';

if(isset($_POST['upload']))
{
$fileName = $_REQUEST[subject_name];
$tmpName = $_FILES['userfile']['tmp_name'];
$fileSize = $_FILES['userfile']['size'];
$fileType = $_FILES['userfile']['type'];

// get the file extension first
$ext = ".pdf";

// make the file name
$uniqueName = $_REQUEST[subject_code] . $_REQUEST[year] . $_REQUEST[semester];

//the unique file name for the upload file
$filePath = $uploadDir . $uniqueName . $ext;

$result = move_uploaded_file($tmpName, $filePath);
n

if (!$result) {
echo "Error uploading file";
exit;
}

if(!get_magic_quotes_gpc())
{
$fileName = addslashes($fileName);
$filePath = addslashes($filePath);
}

$query = "INSERT INTO exam_papers (subject_code, subject_name, lecturer, department, semester, year_of_exam, file_path) ".
"VALUES ('$_REQUEST[subject_code]','$fileName','$_REQUEST[lecturer]','$_REQUEST[department]','$_REQUEST[semester]','$_REQUEST[year]', '$filePath')";

mysql_query($query) or die('Error, query failed : ' . mysql_error());

echo "<br>Files uploaded<br>";

}
?>

</body>
</html>

lindaonline15

5:50 pm on Sep 4, 2008 (gmt 0)

10+ Year Member



ok i got it... it was just a typo...

eelixduppy

5:51 pm on Sep 4, 2008 (gmt 0)



Cool, glad you got it resolved. :)