【发布时间】:2015-05-27 10:23:49
【问题描述】:
这是我的代码。每当我执行此操作时,数据都会以双引号作为“公园大道”存储在数据库中。
if ($_FILES["csv_file"]["size"] > 0)
{
//get the csv file
$file = $_FILES["csv_file"]["tmp_name"];
$handle = fopen($file,"r");
//loop through the csv file and insert into database
do {
if ($data[0]) {
mysql_query("INSERT INTO add_product(product_id, product_name, date) VALUES
(
'".addslashes($data[0])."',
'".addslashes($data[1])."',
'".addslashes($data[2])."'
)
");
}
} while ($data = fgetcsv($handle,1000,",","'"));
//
//redirect
header('Location: http://abcd.adisoftronics.in/index.php/abc/csv_1?success=1');
die;
}
【问题讨论】:
-
使用 str_replace('"',' ',$data[0]);