我正在使用MySQL LOAD DATA INFILE
命令。它显示空白输出,并且没有插入mySQL DB。
mysql_connect("localhost", "user", "pwd*")or die("cannot connect");
mysql_select_db("my_db")or die("cannot select DB");
$sql="LOAD DATA LOCAL INFILE 'users.csv' INTO TABLE usersystem
FIELDS TERMINATED BY ',' ENCLOSED BY '"'
LINES TERMINATED BY '\r\n'
IGNORE 1 LINES
(email,password,fname,lname)";
$result=mysql_query($sql);
if($result){
echo "DONE"
}
else {
echo "ERROR";
}
mysql_close();
为什么不插入行?
答案 0 :(得分:0)
试试这个:
mysql_connect("localhost", "user", "pwd*") or die("cannot connect");
mysql_select_db("my_db") or die("cannot select DB");
$sql = "LOAD DATA LOCAL INFILE 'users.csv' INTO TABLE usersystem" .
" FIELDS TERMINATED BY ',' ENCLOSED BY '\"'" .
" LINES TERMINATED BY '\\r\\n'" .
" IGNORE 1 LINES" .
" (email,password,fname,lname)";
$result = mysql_query($sql);
if ($result){
echo "DONE"
}
else {
echo "ERROR";
}
// close connection
mysql_close();
警告强>
<小时/>MySQL
扩展名已经过时了!使用MySQLi
或PDO
。要了解它们,请使用您最喜欢的搜索引擎。