php - MySQL LOAD DATA INFILE does not insert rows -


i using mysql load data infile command. showing blank output , 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' table usersystem        fields terminated ',' enclosed '"'       lines terminated '\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 insert rows?

try this:

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' table usersystem" .        " fields terminated ',' enclosed '\"'" .        " lines terminated '\\r\\n'" .        "  ignore 1 lines" .        " (email,password,fname,lname)";  $result = mysql_query($sql); if ($result){   echo "done" }  else {   echo "error"; }  // close connection mysql_close(); 

warning


mysql extension horribly outdated! either use mysqli or pdo. learning them, use favorite search engine.


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -