-1

I am using MySQL LOAD DATA INFILE command. It is showing blank output and no insertion in 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();

Why doesn't it insert rows?

4

1 回答 1

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非常过时!使用MySQLiPDO。要学习它们,请使用您最喜欢的搜索引擎。

于 2013-06-29T10:08:51.853 回答