Reply to Re: Strange characters in MYSQL? - ascii characters only.php (0/1)

Your name:

Reply:


Posted by Gleep on 03/21/07 01:14

On 20 Mar 2007 11:01:28 -0700, matthud@gmail.com wrote:

>The following string:
>"US generals ‘will quit’ if Bush orders Iran attack"
>
>is being stored in my table as:
>
>"US generals ‘will quit’ if Bush orders Iran attack"
>
>The only PHP function I'm applying to the string is
>mysql_real_escape_string, and that doesn't appear to be the root of
>the problem. I'm using utf8_general_ci as my collation.
>
>Forgive my ignorance.



user this function on all incoming variables
will clean out the junk characters and replace with ascii

<?php
function asciify($str)
{
$unicode_array = array("&#8211;" => "-",
"&#8212;" => "-",
"–" => "-",
"&#8216;" => "'",
"’" => "'",
"&#8217;" => "'",
"‘" => "'",
"&#8230;" => "...",
"…" => "...",
"“" => "\"",
"&#8220;" => "\"",
"”" => "\"",
"&#8221;" => "\"");
$str = strtr($str, $unicode_array);
return strtr($str, "ŠŒŽšœžŸ¥µÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿ",
"SOZsozYYuAAAAAAACEEEEIIIIDNOOOOOOUUUUYsaaaaaaaceeeeiiiionoooooouuuuyy");
}
?>


darn look like my new reader will not post the correct charas
so I will also attach the file

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация