Reputation: 181
I'm trying to store the image into an array. My php code as below:
$query_search1 = "SELECT profilePicture FROM rocket WHERE username='".$rocketName."'";
$query_exec1 = mysqli_query($db->getConnection(),$query_search1) or die(mysqli_error($db->getConnection()));
$row1 = mysqli_fetch_assoc($query_exec1);
//$rocketPic = $row1['profilePicture'];
$json = array();
//$json['rocket_profile'][] = $row1;
if(mysqli_num_rows($query_exec1)){
while($row2 = $row1){
$json['rocket_profile'][] = $row2;
}
}
Data type for profilePicture is BLOB. Below is the error I got:
Allowed memory size of 134217728 bytes exhausted (tried to allocate 36 bytes)
All I want is to store it as json to be used in Android application.
Upvotes: 0
Views: 79
Reputation: 691
You have an infinity loop, try this:
$query_search1 = "SELECT profilePicture FROM rocket WHERE username='".$rocketName."'";
$query_exec1 = mysqli_query($db->getConnection(),$query_search1) or die(mysqli_error($db->getConnection()));
$json = array();
if(mysqli_num_rows($query_exec1)){
while($row1 = mysqli_fetch_assoc($query_exec1)){
$json['rocket_profile'][] = $row1;
}
}
Upvotes: 1
Reputation: 1681
You can set ini_set('memory_limit', '-1');
before your $query_search1
variable to solve the error :Allowed memory size of 134217728 bytes exhausted (tried to allocate 36 bytes)
But I suggest you to check your logic instead of change the Resources memory Limit. :)
Upvotes: 0
Reputation: 2782
You have an infinite while loop. This consume all your RAM mem. Review your loop logic.
Upvotes: 2