doulv1760 2016-03-08 14:20
浏览 23

Sql停止返回数据而没有错误

I'm using mysql and php to show some data, here is my code :

<?php

require_once('sqlconnect.php');

$sqlQuery = "SELECT name FROM hiltonsmythe.hs_listing_types LIMIT 120"; 
$result = $unity_connection->query($sqlQuery);

$json1 = array();
while($rows = mysqli_fetch_assoc($result)){
    $json1[] = $rows;
}   
echo json_encode($json1);

?>

This works fine when i navigate to the php file, but if i change the LIMIT to 121 it doesnt return anything even though the table has over 300 fields. When i run the select in SQLWorkbench it works fine.

Anyone know what this could be? i will eventually need to return around 400 i am not sure why it is stopping, there is no error at all on firebug.

edit : i added

error_reporting(E_ALL); ini_set('display_errors', 1);

still no results..

enter image description here

This is the sql connection file :

<?php
    class SQLConnection {
        private $mysqli;
        public function __construct ($host, $user, $pass, $name) {
            $this->mysqli = new mysqli($host, $user, $pass, $name);
            $connectionAttempts = 1;
            while ($this->mysqli == null && $connectionAttempts < 5){
                sleep(1);
                $this->mysqli = new mysqli($host, $user, $pass, $name);
                $connectionAttempts++;
            }

            if($this->mysqli->connect_error){
                die("$this->mysqli->connect_errno: $this->mysqli->connect_error");
            }
        }

        public function __destruct(){
            $this->mysqli->close();
        }

        public function query($sql, $params = null){
            $result = $this->mysqli->query($sql);
            return $result;

        }

        public function real_escape_string($string){
            return $this->mysqli->real_escape_string($string);
        }

        public function getConnection(){
            return $this->mysqli;
        }
    }
?>
  • 写回答

2条回答 默认 最新

  • douyan4243 2016-03-08 14:31
    关注

    I think that the problem may be a limit on the script memory. Try to run this code:

    <?php
    
    require_once('sqlconnect.php');
    ini_set("memory_limit","256M"); // add this memory_limit
    $sqlQuery = "SELECT name FROM hiltonsmythe.hs_listing_types LIMIT 120"; 
    $result = $unity_connection->query($sqlQuery);
    
    $json1 = array();
    while($rows = mysqli_fetch_assoc($result)){
        $json1[] = $rows;
    }   
    echo json_encode($json1);
    
    ?>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭