title: Pass MySQL medium blob into IOS NSData\UIImage
body: <p>In my PHP, I'm tying to send an array with data from the database. All values should be accepted as NSString exept one image that is stored as 'medium blob' in the database, and I'm trying to pass it's NSData\UIImage value. </p>
  
  <pre><code>while ($row = mysql_fetch_array($result)) {
  
      $add = array(); 
      $add["Id"] = $row["Id"]; 
      $add["Mail"] = $row["Mail"];
      $add["Category"] = $row["Category"]; 
      $add["Phone"] = $row["Phone"]; 
      $add["Msgs"] = $row["Msgs"];
      //image from blob
      $add["Picture"] = $row["Picture"];
  
      // push single add into final response array 
      array_push($response["adds"], $add); 
  } 
  // success 
  $response["success"] = 1; 
  $response["message"] = "Adds loaded successfully";
  // echoing JSON response 
  echo json_encode($response); 
  </code></pre>
  
  <p>Now in Xcode, all values are received just fine except the image that is NULL. I tried to encode it with base64 in PHP and decode in Objective-C, but xcode collapses because it's still NULL. I tried to define:</p>
  
  <pre><code>header("Content-type: image/png");
  </code></pre>
  
  <p>or</p>
  
  <pre><code>file_put_contents("image.png", $add["Picture"]);
  </code></pre>
  
  <p>but it's always received as NULL. Rows that don't have blobs stored in them return as ' ', only the one with content returns NULL. I'm new to PHP, and I'm sure I'm doing some basic stupid mistake.</p>
  
  <p>BTW my Objective-C code is:</p>
  
  <pre><code>const void *bytes = [[addPicture objectAtIndex:indexPath.row] bytes];
  int length = [[addPicture objectAtIndex:indexPath.row] length];
  NSData* imageData = [[NSData alloc] initWithBytes:bytes length:length];
  aCell.cellBackImg.image = [UIImage imageWithData:imageData];
  </code></pre>