该文件是 /tmp/phpBeoJQ5 。
################ 您可以复制此代码进行测试 #################
include("include/dbclass.inc"); // 可以用 MYSQL.INC 类代替测试
$q = new DB_Sql;
$db = $q->数据库; //定义数据库
mysql_connect('localhost:3306',$q->User,$q->Password);
?>
// 点击“确定”按钮后,开始插入数据
if ($submit == "ok") {
$NO = 1;
while ($csv_data = fgetcsv($fp, 2000, "$termerated")) {
//$num = count($csv_data);
for ( $c=0; $c$table_field_name = "field$c";
$first_3 = substr($$table_field_name, 0, 3);
$first_2 = substr($$table_field_name, 0, 2);
$val_tmp = ($first_3 == "fid" || $first_3 == "int"
|| $first_2 == "id") ?
$csv_data[$c] : "'" 。 $csv_data[$c] 。 “'”;
$val .= $val_tmp 。 “,”;
$var .= $$table_field_name 。 “,”;
}
$val = substr($val, 0, -1);
$var = substr($var, 0, -1);
$query = "INSERT INTO $table ($var) VALUES ($val)";
$val = "";
$var = "";
$q->query($query);
echo "NO.$NO $query
";
$NO;
}
fclose($fp);
}
}
}
?>