Gaz Smith
Gaz Smith

Reputation: 1108

Sql stopping returning data with no error

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;
        }
    }
?>

Upvotes: 0

Views: 193

Answers (2)

Krishna
Krishna

Reputation: 1

Did you try to increase max_allowed_packet in my.ini? please don't forget to restart MySQL after changing this setting.

Upvotes: 0

alexander.polomodov
alexander.polomodov

Reputation: 5524

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);

?>

Upvotes: 1

Related Questions