我有一个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);
}
}