我收到一个 PHP 错误:
Parse Error received on unexpected T_ENCAPSED AND WHITESPACE.
该行:($insert .= "($POST...)
是产生错误的行。
(string)$insert;
if(is_array($_POST['Year']))
{
foreach($_POST['Year'] as $k=>$v)
{
//the following line returns the error
$insert .= "($_POST['Name'][$k], $_POST['One'][$k], $_POST['Two'][$k], $_POST['Four'][$k], $_POST['Eight'][$k], $_POST['Fifteen'][$k], $_POST['LJump'][$k], $_POST['HJump'][$k], $_POST['Shotputt'][$k], $_POST['Discuss'][$k], $_POST['Javelin'][$k], $_POST['Date'][$k], $_POST['Year'][$k]),";
}
$insert = substr_replace($insert ,0,-1);
}
else
{
$insert .= "($_POST['Name'], $_POST['One'], $_POST['Two'], $_POST['Four'], $_POST['Eight'], $_POST['Fifteen'], $_POST['LJump'], $_POST['HJump'], $_POST['Shotputt'], $_POST['Discuss'], $_POST['Javelin'], $_POST['Date'], $_POST['Year'])";
}
$sql="INSERT INTO results_main
(Name, One, Two, Four, Eight, Fifteen, LJump, HJump, Shotputt, Discuss, Javelin, Date, Year)
VALUES
".$insert;
$result = mysql_query($sql) or die(mysql_error());