So I have a database for a forum board, stored in a MySQL database called forum.
Inside it, I have a column called post in a table called forum_posts. There is some HTML I need to replace inside the post column, but it is stored between other characters (mostly text; more precisely, forum board conversations).
I have to replace this line:
<div width="95%" style="margin:8px 26px 4px 26px"><a href="javascript:void(0);" onclick="javascript:spoil(this);"><div class='spoilertop'><b>SPOILER</b> [Show/Hide]</div></a><div style="display: none;" class="spoilermain">
With this line:
<div width="95%" style="margin:8px 26px 4px 26px"><a class='spoilertop' style='display:block;'><b>SPOILER</b> [Show/Hide]</a><div class="spoilermain">
I have tried this SQL (and some of its variations), but it always results to MySQL error.
SELECT * FROM `forum_posts` REPLACE(`post`, `<div width="95%" style="margin:8px 26px 4px 26px"><a href="javascript:void(0);" onclick="javascript:spoil(this);"><div class='spoilertop'><b>SPOILER</b> [Show/Hide]</div></a><div style="display: none;" class="spoilermain">`, `<div width="95%" style="margin:8px 26px 4px 26px"><a class='spoilertop' style='display:block;'><b>SPOILER</b> [Show/Hide]</a><div class="spoilermain">`)
Is there any help?
Just a note if someone needs/wants to see what I did:
It was based on this: http://www.sqlteam.com/article/using-replace-in-an-update-statement
All credits goes to @Teez though!