Hi,
I got a problem retrieving images from a database.
I know how to call an external script like this...
[FONT=courier new]
<html>
<!-- page1.html -->
... blablabla
<img src=get_image.php?pk=123 />
... blablabla
</html>
[/FONT]
...where get_image.php connects to database, retrieves image type and data, sends header and finally echoes the data.
[FONT=courier new]
<?php
//get_image.php
$con = mysql_connect("localhost", "scott", "tiger");
mysql_select_db("dbname", $con);
$res = mysql_query("SELECT img_data, img_type FROM img WHERE img_pk__ = " . $pk);
header(mysql_result($res, 0, "img_type"));
echo(mysql_result($res, 0, "img_data"));
?>
[/FONT]
But that's not what I want... I just want to get things working within one php script.
I've had that it can be done someway like...
[FONT=courier new]
<html>
<?php
$con = mysql_connect("localhost", "scott", "tiger");
mysql_select_db("dbname", $con);
$res = mysql_query("SELECT img_data, img_type FROM img WHERE img_pk__ = " . $pk);
$encoded = base64_encode(mysql_result($res, 0, "img_data"));
//then echo to browser as:
echo "<img src='data:image/x-png;base64, .$encoded . '/>";
?>
</html>
[/FONT]
It works fine on Netscape but does not on Internet Explorer :o((
Any ideas?
Dojcland