I am refactoring old code, including rewriting basic mysql queries to use PDO.
The following works brilliantly in all browsers and for all types of images:
$query = 'SELECT image FROM image WHERE imageid=' . $image_id;
$result = mysql_query($query, $db_conn); querycheck($result);
header("Content-type: image");
echo mysql_result($result, 0);
Unfortunately, however, I rewrite it using PDO, it does not work. I went through all the PDO documentation and standard web search, but none of the recommendations / solutions work.
How to easily get and display from MySQL using PDO and display it?
Edit 1:
Matthew Ratsloff gives what should be the obvious answer below, but that doesn't work. Here is the actual code that I am testing with PDO (and I have tried many options / options):
$connectstring_temp = 'mysql:host=' . $A . ';dbname=' .$B;
$dbh_temp = new PDO($connectstring_temp, $login, $password);
$sql = "SELECT image FROM image WHERE imageid=" . $image_id;
$query = $dbh_temp->prepare($sql);
$query->execute();
$query->bindColumn(1, $image, PDO::PARAM_LOB);
$query->fetch(PDO::FETCH_BOUND);
header("Content-Type: image");
echo $image;
, $image_id . . PDO .