当我尝试运行此代码时:
<?php
$str = "Patty O'Furniture";
if(get_magic_quotes_gpc())
echo stripslashes($str);
?>
输出是Patty O'Furniture
但是当我尝试运行此代码时(将数据上传到数据库表中)
<?php
if ($_FILES[csv][size] > 0) {
//get the csv file
$file = $_FILES[csv][tmp_name];
$handle = fopen($file,"r");
//loop through the csv file and insert into database
do {
if ($data[0]) {
if(get_magic_quotes_gpc())
mysql_query("INSERT INTO sms_recipient (store_id, recipient_name, recipient_phone) VALUES
(
'".$login_id."',
'".stripslashes($data[0])."',
'".stripslashes($data[1])."'
)
");
}
} while ($data = fgetcsv($handle,1000,",","'"));
//
}
?>
仅输出Patty O
。(见截图)
我不确定为什么当我尝试使用函数将数据保存到数据库stripslashes
时它不起作用。