<?php
header('Content-Type: application/json');
include 'config.php';
//
$connection = mysqli_connect($host, $user, $pass, $database) or die('ko the ke noi');
mysqli_query($connection, "SET NAMES 'utf8'"); // importance !
$sql = "SELECT * FROM `book`";
$result = mysqli_query($connection, $sql);
$json = array();
if ($result)
{
$row = mysqli_fetch_array($result);
$json["hello"] = $row['description'];
}
else
{
echo "connect success";
}
$json_print = json_encode($json, JSON_UNESCAPED_UNICODE); // print utf-8
echo $json_print;
echo $json_last_error();
?>
Thứ Tư, 26 tháng 8, 2015
How to return utf-8 when you query MYSQL
Đăng ký:
Đăng Nhận xét (Atom)
Không có nhận xét nào:
Đăng nhận xét