我已经创建了一个CMS,并在localhost中进行了测试,并读取了所有json响应。然而,当我把代码放在一个活的服务器上,我仍然可以插入,视图和编辑数据,但我无法读取任何json响应。而这是一个非常重要的部分,因为我需要他们为我的android应用程序。后端JSON响应
这是我的代码。
<?php
include ("../includes/connect.php");
$string = "";
$newString = "";
$get_posts = "select * from last_game";
$run_posts = mysqli_query($con, $get_posts);
$posts_array = array();
while ($posts_row = mysqli_fetch_array($run_posts))
{
$row_array['id'] = $posts_row['id'];
$row_array['game'] = $posts_row['game'];
$row_array['date'] = $posts_row['date'];
array_push($posts_array, $row_array);
}
$string = json_encode($posts_array, JSON_UNESCAPED_UNICODE);
echo $string;
?>
有错误,我得到的是
Notice: Use of undefined constant JSON_UNESCAPED_UNICODE - assumed
'JSON_UNESCAPED_UNICODE' in /var/www/vhosts/theo-
android.co.uk/httpdocs/manudb/android/last_game_json.php on line 26
Warning: json_encode() expects parameter 2 to be long, string given in
/var/www/vhosts/theo-
android.co.uk/httpdocs/manudb/android/last_game_json.php on line 26
难道是有毛病的PHP版本?
任何想法?
谢谢。
我们不能帮你没有看到你得到的错误...检查浏览器的开发者控制台的JS错误或服务器的PHP错误(如果他们被设置为不显示) –
删除JSON_UNESCAPED_UNICODE常量 –
是!!!它现在正在工作!:)谢谢 – Theo