|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2018-02-18 20:00 UTC] peehaa@php.net
-Status: Open
+Status: Feedback
[2018-02-18 20:00 UTC] peehaa@php.net
[2018-02-18 20:01 UTC] peehaa@php.net
[2018-02-18 20:24 UTC] spam2 at rhsoft dot net
[2018-02-20 02:39 UTC] peehaa@php.net
-Status: Feedback
+Status: Closed
-Assigned To:
+Assigned To: peehaa
[2018-02-20 02:39 UTC] peehaa@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 06:00:01 2025 UTC |
Description: ------------ "CVS" string processing fails to properly parse " (quote) delimited fields. delimited fields containing an ' (apostrophe) fail to parse correctly. Appears that parser recognizes an embedded apostrophe as a field delimiter. My workaround is: while (($data = fgets($handle, 500))) { $data = str_replace("'","\\'",$data); $data = str_getcsv($data, ",",'"'); $query = "INSERT INTO `address` (`fname`,`lname`,`address`,`city`,`state`," . "`postcode`,`aux`)". " VALUES '$data[0]','$data[1]','$data[2]','$data[3]'," . "'$data[4]','$data[5]','$data[6]');"; $result = $db->exec($query); Not all test cases seem to fail. I have had to use the above workaround to update a MySQL table. The below example test script seems to have worked leaving "\\'" in the test field? Anyhow that's my story and I'm sticking to it. Could be the issue is in the PDO MySQL driver? One of 'em needs more testing. Test script: --------------- $data = "\"Got'ta apostrophe you can spare?\""; $data = str_replace("'","\\'",$data); $data = str_getcsv($data, ",",'"');