php - MySQLi CSV Load Data Infile to MySQL (Certain columns in CSV, certain columns in MySQL) -


i have searched last week on this, nothing have found works, , have looked @ documents, , nothing in documents work either.

i have csv (link below download) need upload couple columns mysql, using mysqli. csv platform use serve ads, client name has been changed, data true data 2 days.

here code have upload (there 3 different versions of sql command, have tried around 30 different ones):

<?  (my user information mysql server) $ad_results = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname); ignore_user_abort(true); set_time_limit(9999);  $sql1 =  "load data infile 'csv_file_for_stackoverflow.csv' table ad_info fields terminated ',' lines terminated '\n'   (@col1,@col2,@col6,@col12,@col13,@col14) set client=@col2,impressions_delivered=@col12,date=@col1,impressions_booked=@col13,clicks=@col14,creative=@col6";  $sql2 = "load xml infile '558385_20130815-153744.xml' table item rows identified '<row>'";  $sql3 = "load data infile 'csv_file_for_stackoverflow.csv' table ad_info         fields terminated ','         lines terminated '\n'         ignore 1 lines         (@client, @name)         set           client = @client,           impressions_delivered = @impressions_delivered,           company_id = '1000001'"; mysqli_query($ad_results, $sql3);` mysqli_close($ad_results) ?> 

the mysql database set of columns csv, in case not possible columns, , willing upload data. fun part there 30-40 csv files go through code every day @ 1am, have code select csvs in download folder, need code insert them mysql. thanks! (please reply true answers, have searched everywhere, , nothing have found works, gives me error, or not insert lines mysql, closest have gotten parsing csv , using

mysqli_query($ad_results, "insert ad_info (...)values(...)"); 

this file lives on server, , cron job run php script every night, has ignore user abort, , run time of 9999 seconds. (to make sure gets data). in advance help!

csv file: http://ad-results.com/csv_file_for_stackoverflow.csv

i cannot find mysqli_error($ad_results) call in code. should save response of mysqli_query() in resource-variable $mysqli , display possible mysql error like:

$mysqli=mysqli_query($ad_results, $sql3); if (!$mysqli) echo mysqli_error($ad_results); 

maybe there message waiting after all? ;-)


Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -