[thelist] Odd Behavior last night with MySQL Server
Rob Smith
rob.smith at THERMON.com
Fri Aug 6 14:44:58 CDT 2004
<snip>
> 47,"Home","Books","Audiobooks","Movies, Music & Entertainment",""
>
> When exploded on , yields
Uh, "exploded"?? You must have a violent and noisy office :-)
Whatever you mean by that, it's irrelevant, unless this is a PHP
issue. This MySQL statement:
INSERT INTO ofnav VALUES (430,"Home","Books","Family, Parenting &
Education","",""); -- note the added field on the end! --
:: will work just fine; MySQL doesn't care about the comma when it's
inside a *quoted* string value.
FWIW!
</snip>
Hassan. Let me put it in this light, and maybe you'll see what I see.
$filename = "/..absolute path ../test.csv";
$handle = fopen($filename, "r");
$contents = explode("\r\n", fread($handle, filesize($filename)));
ok. $contents would equal in one example (old version):
47,"Home","Books","Audiobooks","Movies, Music & Entertainment",""
to get the line I did this:
$line = explode(",",stripslashes($contents[$i]));
according to that the array $line would look like:
47
"Home"
"Books"
"Audiobooks"
"Movies
Music & Entertainment"
""
>:: will work just fine; MySQL doesn't care about the comma when
>it's inside a *quoted* string value.
remember, I'm parsing from a text file and lines.
My newer version looks like this
47|"Home"|"Books"|"Audiobooks"|"Movies, Music & Entertainment"|""
$line = explode("|",stripslashes($contents[$i]));
which results in the desired effect:
47
"Home"
"Books"
"Audiobooks"
"Movies, Music & Entertainment"
""
Thanks again for all your help on this.
Rob
More information about the thelist
mailing list