title: Returning blob data from MySQL in PHP and converting to base64_encode to add to an array
body: <p>I'm attempting to retrieve all the data from a table in MySQL and add it to an array.</p>
  
  <p><img src="https://i.stack.imgur.com/e6iFi.png" alt="Click for Table columns structure"></p>
  
  <p>I want to convert the blob into an encoded string and add it to an array with the other two columns and then return it as a JSON string. See below for my attempted code:</p>
  
  <pre><code>&lt;?php 
  //Importing Database Script 
  require_once('dbConnect.php');
  
  //Creating sql query
  $sql = "SELECT * FROM picture";
  
  //getting result 
  $r = mysqli_query($con,$sql);
  
  //creating a blank array 
  $result = array();
  
  //looping through all the records fetched
  while($row = mysqli_fetch_array($r)){
  
      //Pushing name and id in the blank array created 
      array_push($result,array(
          "pictureID"=&gt;$row['pictureID'],
          "listingID"=&gt;$row['listingID'],
          "listingImage"=&gt;$row [base64_encode('listingImage')]
      ));
  }
  
  //Displaying the array in json format 
  echo json_encode(array('result'=&gt;$result));
  
  mysqli_close($con);
  </code></pre>
  
  <p>The code is currently returning with a null value for the blob image.</p>