2

I currently have the following MySQL statement to replace the HTML entity for a single quote with an actual single quote:

update photo_galleries replace(title, ''', '\'');

This statement returns an error. I have tried adding additional backslashes, but this does not help at all. I want to run this command using pure SQL (no PHP, etc.). Any suggestions are welcome and appreciated. Thanks.

2 Answers 2

2

This isn't a valid SQL query, you were probably looking for:

UPDATE photo_galleries
SET title = REPLACE(title, ''', '\'');
Sign up to request clarification or add additional context in comments.

3 Comments

That is exactly what I meant - I accidentally excised the missing part. Oops - and thanks!
No, works great. I previously had unintentionally removed the "SET title = " from the statement and did not notice.
@modulaaron: You may want to mark the answer as accepted, by clicking on the green tick, if it was helpful. And welcome to Stack Overflow :)
2

Your UPDATE statement is invalid. You may want to try:

UPDATE photo_galleries SET title = REPLACE(title, ''', '\'');

The REPLACE() function works correctly:

SELECT REPLACE('hello='test'', ''', '\'') AS output;
+--------------+
| output       |
+--------------+
| hello='test' | 
+--------------+
1 row in set (0.00 sec)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.