Thread: Problems with REPLACE
08-20-13, 04:37 #1Registered User
- Join Date
- Aug 2013
Unanswered: Problems with REPLACE
I have a strange problem with an export-script, the culprit seems to be the replace command:
mysql -h localhost sourcedbname -uUser -pPass -N -q -e "SET NAMES binary;SELECT SQL_NO_CACHE pmtext.pmtextid AS conversation_id, REPLACE(REPLACE(REPLACE(REPLACE(pmtext.title, \'<\', \'<\'), \'>\', \'>\'), \'"\', \'\\"\'), \'&\', \'&\'), fromuserid AS user_id, fromusername AS username, dateline AS start_date, 0 AS open_invite, 1 AS conversation_open, 0 AS reply_count, GREATEST(2, (SELECT COUNT(*) FROM pm WHERE pm.pmtextid = pmtext.pmtextid)) AS recipient_count, pmtextid AS first_message_id, dateline AS last_message_date, pmtextid AS last_message_id, fromuserid AS last_message_user_id, fromusername AS last_message_username FROM pmtext ORDER BY pmtext.pmtextid" > xf_conversation_master.txt;Syntax-error at unexpected word `)'
REPLACE(REPLACE(REPLACE(REPLACE(pmtext.title, \'<\', \'<\'), \'>\', \'>\'), \'"\', \'\\"\'), \'&\', \'&\'),
what could the problem be here? Strangely enough it is the same problem with different versions of mysql.
All rights there have been granted. It doesn't work with:
PHP Version 5.4.4-14+deb7u3
mysql Client API version 5.5.31
pcntl support enabled
PHP 5.4.16 (cli) (built: Jun 11 2013 16:10:39)
Client API version 5.1.66
A little hint would be VERY much appreciated! Thanks!
08-20-13, 06:27 #2Jaded Developer
Provided Answers: 59
- Join Date
- Nov 2004
- out on a limb
i suspect its to do with the escape character sequence. probably the \'"\', \'\\"\'
what I'd suggest you do is debug the replace statements one at a time till you find which component isn't working
as the reported error is "Syntax-error at unexpected word `)'" then it could also be a data errorI'd rather be riding on the Tiger 800 or the Norton