I am trying to write a function to process images in mySQL / PHP but cannot work out how to store the results. I have included a stripped down version of the code to demonstrate the problem.
The blobs in image.image_o are all correctly stored and can be used to output images to the web page. The function runs without error but afterwards the blobs in image.image_r are just a few bytes long and contain text like "Resource id #5"
I am sure I am doing something dumb - just can't see what it is.
function process_images(){
global $mysql
$sql = "select id, image_o from image";
$res = mysqli_query($mysqli, $sql);
if ($res){
while ($ay = mysqli_fetch_array($res, MYSQLI_ASSOC)){
$id = $ay['id'];
$im = imagecreatefromstring($ay['image_o']);
// do something useful with the image
$sql2 = "update image set image_r = '{$im}' where id = $id";
$res2 = mysqli_query($mysqli, $sql2);
if ($res2){
// blah blah
}else{
echo mysqli_error($mysqli)." in res2";
}
}
}else{
echo mysqli_error($mysqli)." in res";
}
}