My problem is that how my query result unreadable for humans. I get this result in browser:
ID: 5 Reg.date: 2016-02-29 18:57:52 C�si
And the name should be 'Cósi'.
The php is in UTF-8, the database is in utf8-hungarian-ci.
So I do the query and after it I put the results into a $user array, and I echo the first 3 item like: echo "ID: " . $user["userID"] . "Reg.date: " . $user["regdate"] . $user["name"];
I tried header('Content-type: text/html; charset=UTF-8');
but it neither works.
I have a innoDB phpmyadmin database, but the server is my father's computer. A xampp, should I search the problem there?
Here is the all php:
$con = mysqli_connect("127.0.0.1", "kxxx", "csxxx", "bxxx");
$password = "asd";
$username = "carrie@gmail.com";
$statement = mysqli_prepare($con, "SELECT * FROM user WHERE email = ? AND password = ?");
mysqli_stmt_bind_param($statement, "ss", $username, $password);
mysqli_stmt_execute($statement);
mysqli_stmt_store_result($statement);
mysqli_stmt_bind_result($statement, $userID, $reg_date, $name, $email, $password, $phonenumber);
$user = array();
while(mysqli_stmt_fetch($statement)){
$user["userID"] = $userID;
$user["regdate"] = $reg_date;
$user["name"] = $name; / which should be "Cósi"
$user["email"] = $email;
$user["password"] = $password;
$user["phonenumber"] = $phonenumber;
}
echo "ID: " . $user["userID"] . "Reg. dátum: " . $user["regdate"] . $user["name"];
echo json_encode($user, JSON_UNESCAPED_UNICODE);
The json_encode is disappears, if empty []
should displayed, but that's not, only the first 3 item of the array.
So I want the C�si to be Cósi. What should I do? I tried to changed meta tag to charset='utf-8', mysql_query("SET NAMES 'utf8'") and the header thing what I mentioned above, all the columns are utf8-hungarian-ci, all the tables and the database is too.... So maybe the server configurations are bed?
When I insert into the database over a php, in the database the 'Cósi' is displays well, everything saved in the database right.
Thank you guys, I resolved it wtih:
mysqli_set_charset($con, 'utf8mb4');