![](/img/trans.png)
[英]I'm trying to query my mysql db with mysqli, however I'm getting memory error
[英]I am trying to rerwrite this as a mysqli query but I keep getting an error
我用PHP和mysql寫了一個查詢,它工作正常並返回數據,我只是想將其重寫為Mysqli函數。
這是我想出的,但文件出現500錯誤。
if (mysqli_connect_errno()) {
printf("Could not talk to the database: ", mysqli_connect_error());
exit();
}
$query("SQL QUERY WORKS FINE");
$data = array();
if ($result = $con->query($query)) {
$tempData = array();
while ($row = $result->fetch_object()) {
$tempData = $row;
array_push($data, $tempData);
}
echo json_encode($myArray);
}
/* free result set */
$result->close();
$con->close();
我看到的第一個問題是您正在嘗試對不存在的變量進行json_encode 。 將$myArray
更改$myArray
$tempData
?
如果關閉調試,則錯誤消息將進入error_log並顯示未定義的變量$ myArray
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.