slouchez — 2012-10-10T18:43:44-04:00 — #1
Here is an example of the code I've tried - as recommended from several searches...
code working in directory:
//get blob (logo)
$sql = "SELECT logo FROM files WHERE fleetnumber='$fleetnumber'";
$query_results = mysql_query($link, $sql);
echo '<img src="'.mysql_result($query_results, 0).'">';
I stored a .png in the variable logo in table 'files'
I get the message "the image "http:///localhost:8000/cc/fleetadmin/" cannot be displayed because it contains errors
<<< that's a PHP message - does it contain a clue to what I'm missing??? I've tried with mysqli_query & mysqli_result - same thing
logic_earth — 2012-10-10T20:57:56-04:00 — #2
Umm...yeah you do not use HTML when outputting binary data like an image. The HTML has to go into a different page that calls for the image. Now unless you actually need to have the images stored within MySQL, it would be better to have them stored on the file system accessible via the web server and only store the path in the database.
starlion — 2012-10-10T21:27:42-04:00 — #3
if you absolutely must store it in the database, then point your image tag to another PHP file, which contains something to the effect of:
But as logic_earth pointed out, it's recommended to store the image data seperately and just put a link to the file in the database.