Deen
Deen

Reputation: 621

Getting empty response, If blob field is there [PHP]

I have beem retrieving the data from mysqli db by php.

$query = "SELECT id, parentId, firstName, middleName, lastName, mobileNumber, photo FROM person WHERE orgId='".$orgId."' ";

$sql = mysqli_query($con, $query);
$data=array();
        if($rows_count!=0){
            while ($rows_fetch = mysqli_fetch_assoc($sql))
            {
                var_dump($rows_fetch);
                $info = $rows_fetch;    
                array_push($data, $info);
                $isSuccessful = true;
                $code = 200;
            }
        }else{
            $isSuccessful = true;
            $code = 202;
        }

        $response = array("resp"=>$data, "code"=>$code, "isSuccessful"=>$isSuccessful);

If blob field is empty, I am getting response. If blob is there, I am getting empty response

Upvotes: 2

Views: 435

Answers (1)

Deen
Deen

Reputation: 621

while ($rows_fetch = mysqli_fetch_assoc($sql))
            {
                //var_dump($rows_fetch);
                $info = $rows_fetch;    
                $info['photo'] = base64_encode($rows_fetch['photo']);
                array_push($data, $info);
                $isSuccessful = true;
                $code = 200;
            }

I have changing blob to base64 code.

Upvotes: 1

Related Questions