There’s an UTF8 problem on my site which I can’t solve (nor understand).
When I use…
$mysqli->set_charset('utf8');
… on my webspace, then special chars are displayed incorrectly. When I delete this function, then all special chars from database queries are displayed correctly. On my local system it’s the opposite (without set_charset(‘utf8’) the chars are not displayed in proper manner)
I also made a test script to see if this is a problem of my webhost. The test works correct on my webspace and locally.
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php
$db = new mysqli( bla bla );
$db->set_charset('utf8');
$sql = "SELECT pages_title
FROM pages
WHERE pages_title = 'Günstige Tablet PCs'";
$result = $db->prepare( $sql );
$result->execute();
$result->bind_result( $title );
$result->store_result();
$result->fetch();
$result->free_result();
echo "Title: ". $title;
Now I’m running out of ideas where the problem could be. Everything is set right:
- The database itself is set to utf8-general-ci
- Files are formatted in UTF8.
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />is set.
Because the test script is running correctly the problem should be within my code, but I got no idea what could cause the error, because I’m not doing anything with utf8_encode/decode or something like that.
Any ideas?? Thanks!!
try out this, should solve it.