Forum Moderators: coopster

Message Too Old, No Replies

T STRING Parse Error

php sytanx error:Please help

         

Techie

4:13 pm on May 31, 2008 (gmt 0)

10+ Year Member



Hi.I use a hosting service called Zymic.There I have made a image hosting system which is in its Beta stage.However,when altering the php something happened:I got a T_STRING error.This didn't happen before (it worked fine before) but now it doesn't work.Here is the document below


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Upload Status - ImageShed</title>
<link rel="icon" href="http://example.com/image-shed/files/Favicon-iShed.ico" type="image/x-icon">
<link rel="shortcut icon" href="http://example.com/image-shed/files/Favicon-iShed.ico" type="image/x-icon">
</head>
<body>
<?php
// Configuration - Your Options
$allowed_filetypes = array('.jpg','.gif','.bmp','.png'); // These will be the types of file that will pass the validation.
$max_filesize = 524288; // Maximum filesize in BYTES (currently 0.5MB).
$upload_path = './files/'; // The place the files will be uploaded to (currently a 'files' directory).

$filename = $_FILES['userfile']['name']; // Get the name of the file (including file extension).
$ext = substr($filename, strpos($filename,'.'), strlen($filename)-1); // Get the extension from the filename.

// Check if the filetype is allowed, if not DIE and inform the user.
if(!in_array($ext,$allowed_filetypes))
die('The file you attempted to upload is not allowed or you didn't specify an image to upload.');

// Now check the filesize, if it is too large then DIE and inform the user.
if(filesize($_FILES['userfile']['tmp_name']) > $max_filesize)
die('The file you attempted to upload is too large.');

// Check if we can upload to the specified path, if not DIE and inform the user.
if(!is_writable($upload_path))
die('You cannot upload to the specified directory, please CHMOD it to 777.');

// We'll start handling the upload in the next step
// Configuration - Your Options
$allowed_filetypes = array('.jpg','.gif','.bmp','.png'); // These will be the types of file that will pass the validation.
$max_filesize = 524288; // Maximum filesize in BYTES (currently 0.5MB).
$upload_path = './files/'; // The place the files will be uploaded to (currently a 'files' directory).

$filename = $_FILES['userfile']['name']; // Get the name of the file (including file extension).
$ext = substr($filename, strpos($filename,'.'), strlen($filename)-1); // Get the extension from the filename.

// Check if the filetype is allowed, if not DIE and inform the user.
if(!in_array($ext,$allowed_filetypes))
die('The file you attempted to upload is not allowed.');

// Now check the filesize, if it is too large then DIE and inform the user.
if(filesize($_FILES['userfile']['tmp_name']) > $max_filesize)
die('The file you attempted to upload is too large.');

// Check if we can upload to the specified path, if not DIE and inform the user.
if(!is_writable($upload_path))
die('You cannot upload to the specified directory, please CHMOD it to 777.');

// Upload the file to your specified path.
if(move_uploaded_file($_FILES['userfile']['tmp_name'],$upload_path . $filename))
echo 'Your file upload was successful, view the file <a href="' . $upload_path . $filename . '" title="Your File">here</a>'; // It worked.
else
echo 'Sorry! There was an error during the file upload. Please try again.'; // It failed :(.

?>
</body>
</html>

The error returned was:


Parse error: syntax error, unexpected T_STRING in /example.com/o/r/a/oracle-nui/htdocs/image-shed/upload.php on line 21

Please help!:(

P.S:I posted this here since I could not access the hosting problems and stuff forum

[edited by: Techie at 4:14 pm (utc) on May 31, 2008]

[edited by: dreamcatcher at 6:03 pm (utc) on May 31, 2008]
[edit reason] No urls please! [/edit]

lorax

4:20 pm on May 31, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Welcome to WebmasterWorld!
Please don't post links. We'll help you without them.

What's on line 21? And what did you modify before you got the error? That particular error typically means the line before the one it identifies is the issue.

cameraman

4:34 pm on May 31, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld Techie!
There's a problem here:
die('The file you attempted to upload is not allowed or you didn't specify an image to upload.');

You need to escape the apostrophe in didn't or use double quotes instead of single quotes for the message.

Techie

5:11 pm on May 31, 2008 (gmt 0)

10+ Year Member



Thanks for the help!

It worked (apostrophes always get me!)

[edited by: Techie at 5:12 pm (utc) on May 31, 2008]