0

以下是我的代码:-

$cat=mysql_real_escape_string($_REQUEST['cat']);
$selqry="select * from quizes where category='$cat'";
$selres=mysql_query($selqry) or die(mysql_error());
$questions = array();
if(mysql_num_rows($selres)) {
while($question = mysql_fetch_assoc($selres)) {
  $questions[] = array('post'=>$question);
}
}
else
{
echo "[{\"Result\":\"No questions in this category\"}]";
exit(0);
}
header('Content-type: application/json');
echo json_encode(array('questions'=>$questions));

现在,quises 表中的所有内容都以正确的 json 格式输出,除了其中包含单引号的字段将输出为 null ..

那我做错了吗?

提前致谢

4

0 回答 0