php 解析错误:语法错误,意外的 T_VARIABLE,期待 '(

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7898633/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 03:36:00  来源:igfitidea点击:

Parse error: syntax error, unexpected T_VARIABLE, expecting '(

phpdate

提问by Tyler Radlick

Ok so im trying to have php check if the date on file is more than that of the current date if not i want it to echo a message but i keep getting this error. Please help!

好的,所以我试图让 php 检查文件上的日期是否大于当前日期,如果不是,我希望它回显一条消息,但我不断收到此错误。请帮忙!

<?php
$infosql = "SELECT * FROM premiersounds_users WHERE customer_id = $id";
$inforesult = mysql_query($infosql) or die(mysql_error());
$info = mysql_fetch_array($inforesult);

//Get date from database
echo $info['party_date'];

//Get current date from server
$format="%m/%d/%y";
$c_date=strftime($format);
//set sessions
$_SESSION['current_date'] = $c_date;
$_SESSION['party_date'] = $p_date;
echo $c_date;

//Check is Current date = lockout date
if $c_date <= $p_date { header("location:/Pages/my_info.php"); } else {echo 'Your account is locked out because your event is too close to allow online editing. Please contact your DJ.';}
?>

回答by Josh

if $c_date < $party_date

if $c_date < $party_date

needs to be:

需要是:

if( $c_date < $party_date )

if( $c_date < $party_date )

回答by MHowey

You have two problems

你有两个问题

this should work

这应该有效

$infosql = "SELECT * FROM premiersounds_users WHERE customer_id = '$id'";
$inforesult = mysql_query($infosql) or die(mysql_error());
$info = mysql_fetch_array($inforesult);

//Get date from database
echo $info['party_date'];

//Get current date from server
  $format="%m/%d/%y";
 $c_date=strftime($format);
  $_SESSION['current_date'] = $c_date;
 echo $c_date;

//Check is Current date < lockout date

//Problem Line//
 if ($c_date <= $party_date) { header("location:/Pages/my_info.php"); } else {echo  'Your account is     locked out because you event is too close to allow online editing. Please contact your DJ.';}

this

这个

customer_id = $id";

should be

应该

customer_id = '$id'";

and this

和这个

if $c_date <= $party_date

should be

应该

if ($c_date <= $party_date)