我无法从数据库获得任何输出。我的数据库中大约有13000个条目。但是,当我尝试将结果限制为350时,输出就在那里,但是当我删除限制时,就会出现空白页。另外,当我获取其他列时,将返回所有13000个查询。现在该怎么办?
<?php
$servername = "localhost:3306";
$username = "root";
$password = "mypassword";
$database = "mydatabase";
$conn = new mysqli($servername, $username, $password, $database);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$info = array();
$sql = "SELECT Customer_Name FROM enquiry ;";
$stmt = $conn->prepare($sql);
$stmt->execute();
$stmt->bind_result($Customer_Name);
while($stmt->fetch()){
array_push($info, $Customer_Name);
}
echo json_encode($info);
?>
答案 0 :(得分:0)
您需要在处理后释放结果。尝试使用这种格式,以便您也可以获得错误消息。
$execute=mysql_query($sql,$conn);
if (!$execute) {
die "Query ($sql) failed: " . mysql_error();
}
while ($row=mysql_fetch_assoc($execute)) {
/* loop through a result set even if you don't think you need to. */
print_r($row);
}
mysql_free_result($execute);
还要在SQL中检查max_allowed_packet。