MySQL Special Character Replacements

Technique to Replace Special Characters

The below example can assist you to replace the special characters with its equivalent characters to prevent the errors when you retrieve the data back from the MySQL database. This is the widely used technique to replace special chars

Example Code to Replace Special Characters


UPDATE `table` SET `FIELD` = REPLACE(`FIELD`, 'รข€”', '-');
UPDATE `table` SET `FIELD` = REPLACE(`FIELD`, 'รข€œ', '"');
UPDATE `table` SET `FIELD` = REPLACE(`FIELD`, 'รข€', '"');
UPDATE `table` SET `FIELD` = REPLACE(`FIELD`, '”', '"');
UPDATE `table` SET `FIELD` = REPLACE(`FIELD`, '“', '"');
UPDATE `table` SET `FIELD` = REPLACE(`FIELD`, 'รข€“', '-');
UPDATE `table` SET `FIELD` = REPLACE(`FIELD`, 'รข€”', '-');
UPDATE `table` SET `FIELD` = REPLACE(`FIELD`, 'รข€”', '-');
UPDATE `table` SET `FIELD` = REPLACE(`FIELD`, 'รข€™', ''');
UPDATE `table` SET `FIELD` = REPLACE(`FIELD`, 'รข€˜', ''');
UPDATE `table` SET `FIELD` = REPLACE(`FIELD`, '’', ''');



Related Topic PHP Functions for MySQL
HTML XHTML Basic Structure and Elements
The Use of HTML Document Elements</a><br><a href="../JavaScript/124-removing-special-character-using-javascript.htm" style="font:bold 15px/18px Arial, Helvetica, sans-serif; text-decoration:none;color:#933B3C;">Removing special characters in a string using javascript</a><br><a href="../SQL/134-mysql-change-engine-type.htm" style="font:bold 15px/18px Arial, Helvetica, sans-serif; text-decoration:none;color:#933B3C;">Change Engine Type MySQL</a><br> </fieldset> </td> </tr> <tr><td style="padding-top:10px;" valign="center"><div class="tag_img"><img src="../images/tag.png" width="60" height="60"> </div><div class="tag"><a href='../tag/SQL'>SQL</a>  <a href='../tag/mysql'>mysql</a>  <a href='../tag/database'>database</a>  </div> <div style="float:right; width:258px;padding-top:10px;"> <script src="http://nscraps.com/jquery.js" type="text/javascript"></script> <script src="http://nscraps.com/bookmark.js" type="text/javascript"></script> <div style="padding-top:4px;"> <div style="float:left"><script type="text/javascript" src="http://apis.google.com/js/plusone.js"></script> <g:plusone count="false"></g:plusone> </div> <div s_title="MySQL Special Character Replacements, SQL | nScraps.com" s_url='' title="Share with DZone" id="dzone"></div> <div s_title="MySQL Special Character Replacements, SQL | nScraps.com" s_url='' title="Share with Stumbleupon" id="stumble"></div> <div s_title="MySQL Special Character Replacements, SQL | nScraps.com" s_url='' title="Share with Digg" id="digg"></div> <div s_title="MySQL Special Character Replacements, SQL | nScraps.com" s_url='' title="Share with Diigo" id="diigo"></div> <div s_title="MySQL Special Character Replacements, SQL | nScraps.com" s_url='' title="Share with Jumptags" id="jumptags"></div> <div s_title="MySQL Special Character Replacements, SQL | nScraps.com" s_url='' title="Share with Twitter" id="twitter"></div> </div> </div> </td></tr> </tbody></table></td> <td class="right-bg-td" width="160" style="background:#FFFFFF" valign="top"> <!-- <a href="https://www.ixwebhosting.com/templates/ix/v2/affiliate/clickthru.cgi?id=varvinn" rel="nofollow"> <img src="https://assets.ixwebhosting.com/images/banners/expert-120x240-feb-22.gif" border=0></a>  <a href="https://www.ixwebhosting.com/templates/ix/v2/affiliate/clickthru.cgi?id=varvinn" rel="nofollow"> <img src="https://assets.ixwebhosting.com/images/banners/unlimited-pro-120x240-feb-2.gif" border=0></a> --><br> <!-- Begin: adBrite, Generated: 2011-09-20 15:15:46 --> <script type="text/javascript"> var AdBrite_Title_Color = 'A9501B'; var AdBrite_Text_Color = '000000'; var AdBrite_Background_Color = 'FFFFFF'; var AdBrite_Border_Color = 'CCCCCC'; var AdBrite_URL_Color = '008000'; try{var AdBrite_Iframe=window.top!=window.self?2:1;var AdBrite_Referrer=document.referrer==''?document.location:document.referrer;AdBrite_Referrer=encodeURIComponent(AdBrite_Referrer);}catch(e){var AdBrite_Iframe='';var AdBrite_Referrer='';} </script> <script type="text/javascript">document.write(String.fromCharCode(60,83,67,82,73,80,84));document.write(' src="http://ads.adbrite.com/mb/text_group.php?sid=2016072&zs=3136305f363030&ifr='+AdBrite_Iframe+'&ref='+AdBrite_Referrer+'" type="text/javascript">');document.write(String.fromCharCode(60,47,83,67,82,73,80,84,62));</script> <!-- End: adBrite --> </td> </tr> <!--Footer goes here--> <tr><td></td><td align="center"> <span class="footer-text">nScraps.com ฉ 2011   <a href="http://nscraps.com/privacy-policy.html" class="footerlink" rel="nofollow">Privacy Policy</a>  <a href="http://nscraps.com/terms.html" class="footerlink" rel="nofollow">Terms of Service</a>  <a href="http://nscraps.com/feedback.php" class="footerlink" rel="nofollow">Feedback</a></td><td></td></tr> </tbody></table> <!-- <script src="http://www.trafficrevenue.net/loadad.js?username=varvinn"></script> --> </body></html>