Question

So i have some problem with UFT-8 in my project, everything else works fine with UTF-8. This is what i got so far.

HEAD in my normal HTML document

<head>
  <meta charset="utf-8">
  ...
</head>

JQuery in my normal HTML File.

function showFiles(){
    setTimeout("$('#pageContent').load('read.php"', function(){ $('#loaderImage').hide(); });",1000);
     }

In this PHP file i connect to the database and SELECT data.

$query = "SELECT * FROM tabke WHERE id = ?";

Then i use PHP while and echo the outputs. Everything works fine only the UTF-8 didn't work.

Schneider Stra�e
Was it helpful?

Solution

Save your php files as UTF-8 also. And you can set your db connection charset to UTF-8 like;

$mysqli = new mysqli("localhost", "user", "pass", "test");
$mysqli->set_charset("utf8");

Edit:

If you are using PDO, you can use following;

$dbh = new PDO("mysql:$connstr",  $user, $password);
$dbh->exec("set names utf8");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top