hey all,
I work on some forms that post true AJAX to a PHP file.
Now the problem is that i can retrieve special characters from the mysql DB and display them allrigth in a textarea field but when i save them back the specialscharacters become (??).
example:
in AJAX:
fo=(document.myform);
postvars=[];
postvars[postvars.length]=“subject=”+encodeURIComponent(fo.subject.value);
AND in PHP to save
$subject=javascript_to_html(utf8_decode(mysql_escape_string($_POST[“subject”])));
and the php function is:
function javascript_to_html($text)
{
$matches = null ;
preg_match_all(’/%u([0-9A-F]{4})/i’, $text, $matches) ;
if (!empty($matches)) for($i = 0;$i < sizeof($matches[0]);$i++)
$text = str_replace($matches[0][$i],
‘&#’ . hexdec($matches[1][$i]) . ‘;’, $text) ;
return $text ;
}
anyhelp how i can save the specialcharacters good?
thanks in advance…
M