dongmaqiu6084 2017-08-06 18:49
浏览 130

使用(PHP)从Mysql获取数据并使用JSON将其发送到typescript / javascript

I have got data from mysql in php, and i want to send it to typescript using JSON. but when load the php page. nothing showed in the screen. It always shows a blank page.

$select  ="SELECT * from `filiere`";
$run = mysqli_query($connect, $select);
$temp = array();

while($row=mysqli_fetch_row($run)) {
    $temp[] = $row;
}
echo json_encode($temp);

from the code, it should show the data in json format.

what it is the problem?

  • 写回答

2条回答 默认 最新

  • dtnpf35197 2017-08-06 18:58
    关注

    In PHP, an unexpeted blank page usually means some kind of error + error reporting turned off.

    Try to turn error reporting on

    ini_set('display_startup_errors',1); 
    ini_set('display_errors',1);
    error_reporting(E_ALL);
    

    EDIT #1: Based on the comments, it seems that json_encode() fails, so returns false (echoing false will result in a blank page).

    The json_last_error() and/or json_last_error_msg() functions should be used to find the error.

    EDIT #2: The first argument of json_encode() must hold only UTF-8 encoded strings.

    评论

报告相同问题?

悬赏问题

  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向