I am using PHP to make a call to MSSQL server.
It is returning a field type ‘varbinary’ that I am using to hold the data on an image
Then I would use the hex field to convert it and display it
This is how I call the database
$conn = new PDO("sqlsrv:Server=$myServer;Database=$myDB", $myUser, $myPass);
$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
} catch (PDOException $e) {
echo 'Connection failed: ' . $e->getMessage();
}
$stmt = $conn->prepare("exec KVEVI_GetImage_IndId @IndId=?" );
$stmt->bindParam(1, $id);
$stmt->execute();
$photo = $stmt->fetch(PDO::FETCH_ASSOC);
$photo= hex2bin( $photo);
echo '<div class="img-outer"><img class="img img-responsive img-circle" src="data:image/jpeg;base64,'.base64_encode( $photo ).'"/></div>';
The code worked perfectly with PHP 5.6
Now the server has been upgraded to PHP 7.2 and now the binary field is coming back as gibberish and the hexbin is throwing an error that it’s not hexdecimals.
What do I need to do to make this work now?
Thank you