Forum Moderators: coopster
Probably just my .php syntax that's causing the problem, and here it is:
<td><img src=\"$intro[4]\"></td>
What syntax do I need to use to get the image to show?
-------------------------------
Also, does the database "need" to be open to display images? I'm using a function to grab the rows from the db. After the function grabs the rows, it closes the db, then returns the "result" to another function that displays everything. So I'm wondering, for image display, does the db need to be open?
As mentioned, everything else comes out just fine.
All assitance, as always, greatly appreciated.
Neophyte
To use the BLOB method, you need something like <img src="image.php?dbreq=IDNO"> in the main page file. Then you have a php script called image.php that takes the GET variable dbreq, uses it as an id to search for your BLOB, and outputs it after having output the appropriate headers, such as:
header('Content-type: image/png'); (if it's a png, for example).
So it means a separate db connection (which is big on overhead time) and a separate db request is necessary for each image grabbed.
Nb, you'll also want to put out some kind of cache headers, since images should usually be cached by ip's, and usually ip's won't cache php files since they don't have any caching information by default. Some ip's also won't cache anything with a parameter in the url, so many ip's won't cache your images at all, have fun paying for your bandwidth and hope you've got a heavy-duty db installation!
Maybe in some future version of http protocol there will be a way of embedding inline image binary information into the html document, like can be done in e-mails, but you'll probably have to wait.
Best practices tend to be simply storing the image in your filesystem, and either having it named according to an id field of your db, or storing the name in the db.
I'll be scouring the net for tutorials on how to do this. Thanks for your help ... anyone else have any input on this issue or additional best practices in regards to same, I'd love to hear it because I'm kind of at a brick wall at this point with this one issue and how to solve it.
Neophyte