I'm not a MySQL expert and am having problem with this...
So, I have a forum board database. There is an outdated code in one of the table that I need to replace. I'm trying to use this:
Update ibf_posts
Set post = 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">');
WHERE post LIKE '%<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">%';
But it's not working. It says:
#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 'WHERE post LIKE '%<div width="95%" style="margin:8px 26px 4px 26px"><a href="ja' at line 1
It's odd, since I tried on my localhost it's working fine. But when I tried in my live server, it doesn't work. My MySQL version (on live server) is MySQL 4.1.22.
Any help?
You should remove the semicolon at the end of the second line, as it indicates that the query is ending, which is not true.
Second line has a ;
at the end. When you erase it then query works
The semicolon (;
) is used to terminate the query ,means we use only one semicolon in the end of every query not in the middle.
I am shocked that your code worked on localhost. Have you checked that the query have worked exactly what you want on localhost or it was doing something else.