0

データベースからエンコードされたデータを抽出するPhpスクリプトがあり、抽出されたデータはメソッドでエンコードされます。抽出された行に のような特殊文字が含まれていない限り、すべて正常に機能します。その場合、結果は得られず、HTML ステータス コードはlatin1_swedish_ciMysqljson_encodeé è .....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);
        }
    }       
4

0 に答える 0