简体   繁体   中英

php error <b>Parse error</b>: syntax error, unexpected ':' in

I am using Flash and PHP to create a JPG. I have the Flash and PHP working as expected on my localhost server. When I upload to server I get the following error:


: syntax error, unexpected ':' in on line :语法错误,第意外':'

And the code:

<?PHP
date_default_timezone_set('America/Los_Angeles');

$targetFilename = date(‘YmdHis’).’_’.mt_rand().’.jpg’;

$serverpath = ‘http://www.mysubdomain.myserver.com';
$directoryPath = ‘/newimagesfolder/‘;

$target_path = $_SERVER['DOCUMENT_ROOT'].$directoryPath.$targetFilename;

if ( move_uploaded_file( $_FILES[ 'userfile' ][ 'tmp_name' ], $target_path ) ) 
{
    echo $serverpath.$directoryPath.$targetFilename;
} 
else
{
     echo "error";
}
?>

Thank you in advance for your time.

You're using the wrong quotes. ' should be normal single quotes ' . What's odd is you have them correct elsewhere in this code. Looks like a probable cut-and-paste error to me.

You have used ' , you need use single or double ' ' or " quotes

 $targetFilename = date("YmdHis")."_".mt_rand().".jpg";

 $serverpath = "http://www.mysubdomain.myserver.com";
 $directoryPath = "/newimagesfolder/";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM