Im trying to replace an adsense code to wrap it in <center></center> html mark. This is the request I am doing : UPDATE wp_posts SET post_content = replace(post_content,"<script type="text/javascript"><!-- google_ad_client = "pub-xxxxxxxxxxxxxxxxxxxx"; /* 300x250, created 2/20/09 */ google_ad_slot = "xxxxxxxxxxxxxxxx"; google_ad_width = 300; google_ad_height = 250; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>","<center><script type="text/javascript"><!-- google_ad_client = "pub-xxxxxxxxxxxxxxxxxxx"; /* 300x250, created 2/20/09 */ google_ad_slot = "xxxxxxxxxxxxxxxx"; google_ad_width = 300; google_ad_height = 250; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script></center>"); Code (markup): However, It cannot execute the command as I get a mysql syntax error problem. What could be the problem ?
Write UPDATE wp_posts SET post_content = <script type="text/javascript"><!-- google_ad_client = "pub-xxxxxxxxxxxxxxxxxxxx"... WHERE post_content = THE REPLACEMENT; THE REPLACEMENT - the content which you want to replace. Also pay attention to quotes.
you can do something like $variable = perform the change UPDATE wp_posts SET post_content='$variable' WHERE post_content=OLD_CONTENT
$query = "UPDATE wp_posts SET post_content = '<script type=\"text/javascript\"><!-- google_ad_client = \"pub-xxxxxxxxxxxxxxxxxxxx\"...' WHERE post_content = THE REPLACEMENT;" Just add \ before every " in NEWCONTENT.