0

I'm trying to figure out how to change a string with another string in mySQL. I don't have much experience with databases. I've read several answers here, but I'm still getting errors.

This is what I started with

UPDATE wp_posts SET post_content = REPLACE (
post_content,
'whatever',
'<a href="https://www.notarealdome.com" onClick="ga('send', 'event', 'Banner', 'Link', 'Page');" target="_blank" rel="noopener noreferrer">Hello</a>');

but it keeps giving me errors.

So, I started to escape special characters like ;(),'_> but I still get an error message. What am I missing?

UPDATE wp_posts SET post_content = REPLACE (
post_content,
'whatever',
'<a href="https://www.notarealdomain.com" onClick="ga(''send''\, ''event''\, ''Banner''\, ''Link''\, ''Page''\)\;" target="\\_blank" rel="noopener noreferrer"\>Hello</a\>');
WendiT
  • 595
  • 2
  • 9
  • 26
  • Does this answer your question? [How do I escape a single quote in SQL Server?](https://stackoverflow.com/questions/1586560/how-do-i-escape-a-single-quote-in-sql-server) – PM 77-1 Apr 18 '20 at 01:58
  • No I read that post, but it didn't help me, bceause my question is more than single quotes. – WendiT Apr 18 '20 at 02:09
  • I've tried escaping the single quotes with another quote or backslash but I'm still getting an error – WendiT Apr 18 '20 at 02:11
  • Thank you for the link. I found out why it's causing an error. – WendiT Apr 19 '20 at 07:24

0 Answers0