I have a problem to get in a session array from php into a javascript, I tried to do it with json_encode, but I got problem with that since json not take swedish charatar and I need to have it in the array, any other suggestion how to do it!
I´m setting the sessions array here, the print_r is only for checking so it´s correct
while($row2[]=mysql_fetch_array($result2))
$_SESSION['row2'] = $row2;
print_r($_SESSION['row2'][0][0]);
print_r($_SESSION['row2'][0][1]);
print_r($_SESSION['row2'][0][2]);
and in my javascript i tried this
var row2 =<?php echo json_encode($_SESSION['row2']) ?>;
console.debug(row2);
Suggestion: Tell your database-client that you expect the data to be encoded as UTF-8 when you request/fetch it from the database. You do this by setting the client character encoding, see
mysql_set_charsetDocs.When you retrieve the data encoded as UTF-8 you can use it with
json_encodeand your website script’s can properly receive it.