【发布时间】:2018-08-24 22:37:18
【问题描述】:
array_push 命令后数组$response 为空,我不知道为什么。我测试了数组$product 是否已填充并且确实填充了。
if (mysqli_num_rows($result) > 0) {
$response = array();
$result = mysqli_fetch_array($result,MYSQLI_ASSOC);
$product = array();
$product[name] = $result['name'];
$product[inn] = $result['inn'];
$product[analgetikagroup] = $result['analgetikagroup'];
$product[wholevel] = $result['wholevel'];
$product[dailydose] = $result['dailydose'];
$product[contraindication] = $result['contraindication'];
$product[sideeffect] = $result['sideeffect'];
$product[gastricprotection] = $result['gastricprotection'];
$response[success] = 1;
$response[product] = array();
array_push($response[product],$product);
echo json_encode($response);
【问题讨论】:
-
在您的脚本顶部放置
error_reporting(E_ALL);,然后在您修复代码中的所有其他问题时,您会发现导致问题的特定错误。
标签: php mysql arrays database mysqli