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

时间:2011-10-26 04:07:44

标签: php date

好吧所以我试图让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.';}
?>

2 个答案:

答案 0 :(得分:3)

if $c_date < $party_date

需要:

if( $c_date < $party_date )

答案 1 :(得分:2)

你有两个问题

这应该有效

$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.';}

customer_id = $id";

应该是

customer_id = '$id'";

和这个

if $c_date <= $party_date

应该是

if ($c_date <= $party_date)