Things I don't like about that tutorial
A sample php3 script (...)
Not having looked closely at it, I've no idea if it would work or not, but the current PHP version is 5.3, and 6 is in the making.
This would store the actual image in the database, whereas I prefer to store a filename in the db and keep the data as files.
@MYSQL_CONNECT("localhost","root","password");
@ is the error supression operator. Bad and nasty.
Use of uppercase in function names. Well, it does work since PHP is case insensitive when it comes to functions (but not variables). I'd stick to lowercase for PHP's built in functions (as they're written in the documentation at www.php.net, and any other function the same way it is declared. For member methods that is often camelCasingForMemberMethods().
Use mysqli (i stands for improved).
If you keep the files on disk instead of in the db, all you need is
// probably want to rename the table from bin_data to image since it no longer contains binary data.
$result = $mysqli->query("SELECT filename from bin_data");
// output doctype, head and body tags here
if ($result) (
while ($row = $result->fetch_assoc())
echo '<img src="/path/to/images/' . $row['filename'] .'" alt="" />';
}
Else you need to instead first select the id, and then make your image tags to look like
echo '<img src="getImage.php?id=' . $row['id'] . '" alt="" />';
And then you'd need a new script, getImage.php to access the database again, not just once, but once per image (the browser sends one request per image). And that script could look like the one in the tutorial. You'd just need to use $_GET['id'] in your sql where clause.