Problem importing CSV file
Posted: Tue May 02, 2006 2:18 pm
Straightforward noob question I hope. Can anyone confirm for me if php has a problem parsing csv files containing '&'. Im trying to import from a file that contains urls, subsequently loading them into a database. Im getting a syntax error in the SQL command that performs the load, which when echoed to the screen looks like:
insert into TABLE values ('0','blahblah' ,'http://www.domain.com/page?a=1221696&b=17328∏=12227345','4.59','0','some text.','some more text','999')
The csv file contains the data as follows
'0'|'blahblah' |'http://www.domain.com/page?a=1221696&b=17328&prod=12227345'|'4.59'|'0'|'some text.'|'some more text'|'999'
The section of code hilighted in red is my concern the &prod seems to be getting converted to ∏? I am using fgets() to import and explode to assign the values to an array. Is this the correct approach or is there another method I should use. (Note the CSV file is actually double quoted not single quoted as shown)
TIA.
Stephen.
insert into TABLE values ('0','blahblah' ,'http://www.domain.com/page?a=1221696&b=17328∏=12227345','4.59','0','some text.','some more text','999')
The csv file contains the data as follows
'0'|'blahblah' |'http://www.domain.com/page?a=1221696&b=17328&prod=12227345'|'4.59'|'0'|'some text.'|'some more text'|'999'
The section of code hilighted in red is my concern the &prod seems to be getting converted to ∏? I am using fgets() to import and explode to assign the values to an array. Is this the correct approach or is there another method I should use. (Note the CSV file is actually double quoted not single quoted as shown)
TIA.
Stephen.