Question

I have a PHP script that takes an image from an Oracle database and saves it into a MySQL database.

It worked fine until I upgraded to PHP 5.3.3 from PHP 5.1.6. The part that queries the Oracle database no longer works. It can query all fields apart from the image field. I believe it is a BLOB.

For instance, the below code outputs Resource id #6

$sql2 = "SELECT CREATIVE FROM creative WHERE id = 10314612";
    foreach($oci->query($sql2) as $row2) {
        echo $row2['CREATIVE']; 
    }
Was it helpful?

Solution

I've finally fixed it.

The code now looks like this:

$stmt = $dbcon->prepare( 'SELECT CREATIVE FROM creative WHERE id = 10314612'); 
$stmt->execute(); 
$res = $stmt->fetchAll( PDO::FETCH_ASSOC ); 

for( $i=0; $i<count($res); $i++ ){ 
  $data = stream_get_contents( $res[$i]['CREATIVE'] ); 
} 

Thanks for your help Passerby.

I don't understand why it works. I just copied the above from one of the examples on php.net

If anyone knows why, it would be great if they could post it here :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top