jonw118 Posted June 3, 2008 Share Posted June 3, 2008 Hello all- I thank you greatly in advance for any help... I have a CSV file I am importing into my MySQL database and have a problem: One of the cells I am importing uses quotations marks in the description (they need to be there!), but unfortunately, when I import it changes the quatations mark to a ? mark sign. I changed "Fields terminated by" to a "+" and changed "fields enclosed by" to a ","... but this did nothing for me. Again, I'd appreciate any help. Thanks! Link to comment https://forums.phpfreaks.com/topic/108537-importing-csv-files-quatations-marks-appear-as-a-mark/ Share on other sites More sharing options...
rubing Posted June 3, 2008 Share Posted June 3, 2008 Those aren't regular quotes you're dealing with...they are 'Magic Quotes'! And a magical pain in the ass. Try replacing them as follows: $string = preg_replace('/[\x91\x92]/u', "'", $string); $string = preg_replace('/[\x93\x94]/u', '"', $string); Link to comment https://forums.phpfreaks.com/topic/108537-importing-csv-files-quatations-marks-appear-as-a-mark/#findComment-556553 Share on other sites More sharing options...
jonw118 Posted June 3, 2008 Author Share Posted June 3, 2008 Oh wow, so right now the cell reads: W90” x D39” x H31” In the CSV file what would I change that to read??? Is this what you are saying? W90string = preg_replace('/[\x91\x92]/u', "'", $string); $string = preg_replace('/[\x93\x94]/u', '"', $string); x D39string = preg_replace('/[\x91\x92]/u', "'", $string); $string = preg_replace('/[\x93\x94]/u', '"', $string); x H31string = preg_replace('/[\x91\x92]/u', "'", $string); $string = preg_replace('/[\x93\x94]/u', '"', $string); Link to comment https://forums.phpfreaks.com/topic/108537-importing-csv-files-quatations-marks-appear-as-a-mark/#findComment-556561 Share on other sites More sharing options...
rubing Posted June 3, 2008 Share Posted June 3, 2008 sorry i should've explained that better. I was giving advice on how to replace magic quotes with normal quotes in a php script, which you could do prior to an INSERT query. I'm not sure how you would issue this command in a text editor. If nobody else answers here, just look up 'find and replace magic quotes' on google. Link to comment https://forums.phpfreaks.com/topic/108537-importing-csv-files-quatations-marks-appear-as-a-mark/#findComment-556762 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.