'附近使用正确的语法所以我不知道这里的交易是什么......下面的代码产生代码后面的mysql错误。错误:检查手动MySQL服务器版本是否在'
$fcontents = file("inventory.csv");
for ($i = 1; $i < sizeof($fcontents); $i++) {
$line = trim($fcontents[$i]);
$arr = explode(',', $line);
$values = implode(',', $arr);
$values = str_replace('&', 'and', $values);
$sql = 'INSERT INTO inventory (dealerid, name, vin, stock, newused, year, ' .
'make, model, series, body, color, intcolor, price, retailprice, ' .
'miles, transmission, engine, restraint, certified, photourl, ' .
'comments, flag, options, citympg, hwympg) ' .
'VALUES mysql_real_escape_string(' . $values . ')';
mysql_query($sql);
echo $sql.'<br><br>';
if (mysql_error()) {
echo mysql_error() .'<br><br>';
}
}
您的SQL语法错误;检查对应于您的MySQL服务器版本的手册,以使用正确的语法以使用'
RESOLVED !!!所以我想后的解决愚蠢,愚蠢的单引号,倾倒在mysql中的.csv文件时,双引号毛刺......见下文:
$fcontents = file("http://pathtofile.com/inventory.csv"); for($i=1; $i < sizeof($fcontents); $i++) { $line = trim($fcontents[$i]); $arr = explode(",", $line); $arr = str_replace ("'","'", $arr); $values = implode("','", $arr); $values = str_replace("\"',",'\'",', $values); $values = str_replace(",'\"",',"\'', $values); $values = str_replace("&", "and", $values); $sql = "INSERT INTO vehicles.inventory (dealerid,name,vin,stock,newused,year,make,model,series,body,color,intcolor,price,retailprice,miles,transmission,engine,restraint,certified,photourl,comments,flag,options,citympg,hwympg) VALUES ('".$values."')"; mysql_query($sql);
什么是实际查询? – 2010-10-19 22:36:02