我有一个Php
脚本应该latin1_swedish_ci
从Mysql
数据库中提取编码数据,然后使用json_encode
方法对提取的数据进行编码,除非提取的行包含特殊字符,否则一切正常é è .....
,在这种情况下我没有得到任何结果,并且 HTML 状态代码是200
那是我的功能
public function categorie()
{
// Cross validation if the request method is GET else it will return "Not Acceptable" status
if($this->get_request_method() != "GET"){
$this->response('',406);
}
$sql = mysql_query("SELECT * FROM categorie", $this->db);
if(mysql_num_rows($sql) > 0)
{
$result = array();
while($rlt = mysql_fetch_array($sql,MYSQL_ASSOC)){
$result[] = $rlt;
}
// If success everythig is good send header as "OK" and return list of users in JSON format
$this->response($this->json($result), 200);
}
$this->response('',204); // If no records "No Content" status
}
private function json($data){
if(is_array($data)){
return json_encode($data);
}
}