为什么我的mySQL查询只包含7列?每次我尝试添加第8列名时,页面就会中断。示例:
不工作:
$result = mysqli_query($conn, "SELECT name, fibre, sugar, img, kcal, carbs, protein, fat FROM table");
$names = array();
$fields_num = mysqli_num_fields($result);
if(mysqli_num_rows($result) > 0) {
while($row = mysqli_fetch_assoc($result)) {
$names[] = $row;
}
} else {
echo "0 results";
}确实有效:查看从查询中删除的“fat”
$result = mysqli_query($conn, "SELECT name, fibre, sugar, img, kcal, carbs, protein FROM table");
$names = array();
$fields_num = mysqli_num_fields($result);
if(mysqli_num_rows($result) > 0) {
while($row = mysqli_fetch_assoc($result)) {
$names[] = $row;
}
} else {
echo "0 results";
}我也尝试过用不同的列名从表,但这并不重要,它们仍然不工作。是的,所有的列都拼写正确。
有什么方法可以查询超过7个列名吗?也是:使用mysqli_query($conn, "SELECT * FROM table");也不起作用!?这里发生什么事情??
发布于 2015-04-08 18:15:38
试图从表格中提取太多的数据:
在PHP日志中找到:[08-Apr-2015 17:49:14 UTC] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 5 bytes)。
必须重新检查代码,才能发现循环中的效率低下。
还将LIMIT 10添加到查询的末尾,以减少表工作负载。
https://stackoverflow.com/questions/29521241
复制相似问题