Mysql 为什么在数据库中查找和替换javascript时,SQL中会出现错误

Mysql 为什么在数据库中查找和替换javascript时,SQL中会出现错误,mysql,sql,Mysql,Sql,我试图在phpMyAdmin中运行查找和替换,因为愚蠢的黑客在我设计的网站中插入了一个db。我正在寻找出现在600多篇不同帖子中的特定文本字符串: <script src='https://hotopponents.site/site.js' type='text/javascript'></script> 我不断地发现这个错误: 错误:未知标点符号字符串@67 这是查找和替换正在尝试运行的SQL查询 SELECT `post_content`, REPLACE(`

我试图在phpMyAdmin中运行查找和替换,因为愚蠢的黑客在我设计的网站中插入了一个db。我正在寻找出现在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
选择'post\u content',替换('post\u content','',''),从'db709131568'中计数(*)。'wp\u posts',其中'post\u content'类似'%'按'post\u content'顺序按'post\u content'ASC对utf8\u bin组进行排序

除了手动编辑600多个单独的内容字符串之外,我还能做什么?

您需要通过将单引号加倍来转义单引号

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
选择'post\u content',替换('post\u content','',''),从'db709131568'中计数(*)。'wp\u posts',其中'post\u content'类似'%'按'post\u content'顺序按'post\u content'ASC对utf8\u bin组进行排序

(说到逃逸,您也可以考虑在显示用户输入的内容时使用HTML转义)。

< P>因为您正在使用PHPMyAdmin,转到搜索选项卡>查找和替换

  • 按原样输入完整的
    ,选择列并选中“使用正则表达式”

避开这些引语可能会有所帮助,'