我试图在phpMyAdmin中运行查找和替换操作,因为愚蠢的黑客已在我设计的网站中插入了数据库。我正在寻找出现在600多个不同帖子中的特定文本字符串:
<script src='https://hotopponents.site/site.js' type='text/javascript'></script>
我不断收到此错误:
错误:@ 67未知的标点字符串
这是SQL查询查找并替换正在尝试运行;
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
除了手动编辑600多个单独的内容字符串外,我还能做什么?
答案 0 :(得分:1)
您需要通过将单引号加倍来对其进行转义。
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
(谈到转义符,您可能还考虑在显示用户输入的内容时使用HTML转义符。)
答案 1 :(得分:0)
由于您使用的是phpmyadmin,请转到搜索标签>查找并替换
<script src='https://hotopponents.site/site.js' type='text/javascript'></script>
,选择该列并选中“使用正则表达式”