我正在尝试将 excel 文件插入数据库我的代码是:
<?php
require_once 'Excel/reader.php';
$data = new Spreadsheet_Excel_Reader();
$data->setOutputEncoding('CP1251');
$data->read('Excel/exceltestsheet.xls');
$conn = mysql_connect("localhost","root","");
mysql_select_db("dbname",$conn);
for ($x == 2; $x <== count($data->sheets[0]["cells"]); $x++)
{
$name = $data->sheets[0]["cells"][$x][1];
$extension = $data->sheets[0]["cells"][$x][2];
$email = $data->sheets[0]["cells"][$x][3];
$sql = "INSERT INTO msg (name,extension,email)
VALUES ('$name',$extension,'$email')";
echo $sql."\n";
mysql_query($sql);
}
?>
当我插入时,我收到一个错误,即
Parse error: syntax error, unexpected '=' in C:\wamp\www\uploadexcel.php on line 11