我收到了这个错误:
致命错误:允许的内存大小为134217728字节已用尽(尝试分配> 32字节)在路径/ / 1phpquery.php上>第24行
第24行
while($ r = $ mysqli-> query($ query)){
完整的代码是:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
$instr = "CCBOT";
require("dbconnect.php");
$query = 'SELECT LgSpecNet, SmSpecNet, CommNet FROM cot WHERE Ticker = "$instr" LIMIT 5';
if ($result = $mysqli->query($query)) {
$table = array();
$table['cols'] = array(
array('label' => 'Large Spec Net', 'type' => 'number'),
array('label' => 'Small Spec Net', 'type' => 'number'),
array('label' => 'Commercial Net', 'type' => 'number')
);
$rows = array();
while ($r = $mysqli->query($query)) {
$temp = array();
$ra = $r->fetch_assoc();
$temp[] = array('v' => (int) $ra['LgSpecNet']);
$temp[] = array('v' => (int) $ra['SmSpecNet']);
$temp[] = array('v' => (int) $ra['CommNet']);
$rows[] = array('c' => $temp);
}
$result->free();
$table['rows'] = $rows;
$jsonTable = json_encode($table);
echo $jsonTable;
}
$mysqli->close();
?>
答案 0 :(得分:1)
您无休止地重新运行查询。变化
while ($r = $mysqli->query($query))
要
while ($ra = $result->fetch_assoc())
删除该行:
$ra = $r->fetch_assoc();