CSV Encoding Issue on PHP upload -


i receive csv file looks straightforward.

i run on , tells me ascii.

echo mb_detect_encoding($fhandle , "auto");      

however when run import code: doesnt work correctly.

$sql= "load data local infile '". $fhandle ."' table sys6_impbet fields     terminated ',' optionally enclosed '\"' lines terminated '\n'  ignore 1 lines  (       accno_1,      mtgdate,      code,      venue,      location,      pool,      eventno,      gross_sales,      refunds,      turnover,      dividends,      profit_loss);" ; 

it brings in correct number of records puts null or 0 in every field / record. reading file sees records won't values.

heres small sample:

accno_1,mtgdate,code,venue,location,pool,eventno,gross_sales,refunds,turnover,dividends,profit_loss 66096159,12/07/2015,gallops,penola,sa,treble,0,279.00,0.00,279.00,"1,955.70","1,676.70" 66096159,12/07/2015,gallops,warrnambool,vic,treble,0,"1,048.00",0.00,"1,048.00","2,672.80","1,624.80" 66096718,12/07/2015,gallops,kalgoorlie,wa,win,2,783.00,0.00,783.00,"1,174.50",391.50 66096718,12/07/2015,gallops,penola,sa,win,6,204.00,0.00,204.00,"1,143.00",939.00 66096718,12/07/2015,gallops,sha tin,hk,win,4,197.00,0.00,197.00,"2,064.00","1,867.00"

is encoding problem.

if open file in notepad , save encoding utf-8 , save down. above code works , imported.

but cant every file every day??

any ideas can try?

i have tried no different:

$fhandle = mb_convert_encoding($fhandle, "utf-8", "ascii");  

s

first check internal encoding used php

echo mb_internal_encoding();

then set required one

mb_internal_encoding("utf-8");


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -