简体   繁体   English

php error Parse error :语法错误,意外':'in

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

I am using Flash and PHP to create a JPG. 我正在使用Flash和PHP来创建JPG。 I have the Flash and PHP working as expected on my localhost server. 我在我的localhost服务器上按预期运行Flash和PHP。 When I upload to server I get the following error: 当我上传到服务器时,我收到以下错误:


Parse error : syntax error, unexpected ':' in /home/carlosrg/public_html/mysubdomain/image.php on line 6 解析错误 :语法错误,第6/home/carlosrg/public_html/mysubdomain/image.php中的意外':'

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/";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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