MySQL search and replace syntax error

2019-03-06 11:38发布

I have the following query and get the below error message:

update `wp_posts` set  `post_excerpt` = replace( `post_excerpt`, "[av_font_icon icon='ue82d' font='entypo-fontello' size='14px' position='left' color='' custom_class=''][/av_font_icon]", '') where instr( `post_excerpt`, "[av_font_icon icon='ue82d' font='entypo-fontello' size='14px' position='left' color='' custom_class=''][/av_font_icon]") > 0;

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"[av_font_icon icon='ue82d' font='entypo-fontello' size='14px' position='left' c' at line 1

I am trying to find the shortcode within my wordpress database and remove it. Does anyone know what is wrong? many thanks

2条回答
我只想做你的唯一
2楼-- · 2019-03-06 11:57

You should escape the single quotes in the string you are matching, using ''

查看更多
相关推荐>>
3楼-- · 2019-03-06 12:13

Why don't you use the "Database Search And Replace Script In PHP"? All you have to do is place it in the root folder and run it in your browser. https://interconnectit.com/products/search-and-replace-for-wordpress-databases/

That's what I use and have never had a problem. Just make sure to make a back up just in case.

Run a search for the short code and replace it with an empty field.

查看更多
登录 后发表回答