i have the following bit of code:
function appear($data)
{
$output = '';
$unsee = unserialize ( $data );
if (is_array ( $nsee ))
{
$output .= '<table>' . "";
foreach ( $nsee as $button )
{
$output .= loadbutton ( $button);
}
$output .= '
<tr><td>IP</td>
<td>' . $_SERVER ['REMOTE_ADDR'] . '</td></tr>' . "";
$output .= '</table>' . "";
}
return $output;
}
function loadbutton($button)
{
$output = '';
$output .= '<tr>' . "";
$output .= '<td>';
$output .= $button ['values'];
$output .= '</td><td>';
$output .= $_POST [strtolower ( $button ['values'])] ;
$output .= '</td>' . "";
$output .= '</tr>' . "";
return $output;
}
when i use the appear function for the english serialized data, it works perfectly and outputs fine.
But when i use it for the arabic serilaized data. everything works except the arabic letters appear as “????” and not as actual arabic letters.
I have verified the data in the database, everything is UTF-8, and everything is valid db wise and saving serilaized wise. but the output and unserialization is incorrect.
Do you know a way to fix this?
Does unserialization support arabic letters? if not then why does it save arabic letters correctly but not fetches them?
EDIT:
The problem i believe is in the call $button [‘values’].
my $button array is
array ( 'values' => 'Field Value')
no solution comes to mind. i know it should work.
SOLUTION:
The problem was in my mysql insert statement of the serialized data. i was inserting in latin. a simple, idiotic mistake.
Thank you for your help.
Make sure you have set in your HTML document:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>or have it set using an HTTP header by placing this at the TOP of your PHP code BEFORE any content is output:
header('Content-Type: text/html; charset=utf-8');The browser is not using the correct character set, and is thus displaying
?in place of those characters.Also use:
As
strtolower()will not properly lowercase multi-byte chars.