CSV import to MySQL character (comma) escape issue

Cancelled Posted Jan 18, 2010 Paid on delivery
Cancelled Paid on delivery

I need someone to fix this issue: the script below is supposed to load a csv file into my cooresponding database table, the data may contain any set of characters and not give errors when importing,

my issue is that i need to be able to save a csv file with commas as a part of the data, as well as any character, and still have it import correctly.

Sample csv format:

Column 1 Column 2 Column 3 Column 4 Column 5 Column 6

8 dataspecchar/*-+?><:; data3 data4 !@#$%^&*() data6

Script:

$target = "mycsvfile.csv";

$fcontents = file ($target);

$count=0;

for($i=0; $i<sizeof($fcontents); $i++) {

$line = trim($fcontents[$i]);

$arr = explode(",", $line);

$sql = "insert into products values ('".

implode("','", $arr) ."')";

mysql_query($sql);

$count++;

if(mysql_error()) {

echo mysql_error() ."<br>\n";

}

else{

$Status_Message = "CSV file imported, $count items added to the database";

}

}

PHP

Project ID: #592961

About the project

8 proposals Remote project Active Jan 27, 2010

8 freelancers are bidding on average $38 for this job

TakeReal

Original script works if you don't use "," as part of field content, Right? Please, send me your CSV file. I will rewrite script to allow you import data with comma and other chars.

$40 USD in 1 day
(1254 Reviews)
7.5
DesignSolutionSW

Please check PM.Thanks.

$30 USD in 0 days
(57 Reviews)
7.0
onready

I am ready & available.

$45 USD in 0 days
(39 Reviews)
5.1
msgaruba

please read pmb thansk

$30 USD in 1 day
(13 Reviews)
4.2
skilledsir

hello.i am skilled in mysql and php.i can start it right now.

$30 USD in 0 days
(15 Reviews)
3.7
khushigupta

dear... can u send me the demo link for that

$70 USD in 1 day
(0 Reviews)
0.0