Ah, still no picture. 
I moved the code as instructed, and it is below. The page is actually on a site that I only use for testing, so the username and password are not significant. The entire database will be deleted and another created on a live site.
Code:
<?php
// Connect and select.
if ($dbc = @mysql_connect ('MYSQLA19.webcontrolcenter.com', 'kevinchase', 'kevinchase')) {
if (!@mysql_select_db ('tajtene')) {
die ('<p>Could not select the database because: <b>' . mysql_error() . '</b></p>');
}
} else {
die ('<p>Could not connect to MySQL because: <b>' . mysql_error() . '</b></p>');
}
if(isset($_GET['photo'])) {
$r = mysql_fetch_array(mysql_query('SELECT Photo FROM Authors WHERE Last_Name="' . $_GET['first'] . '" AND First_Name="' . $_GET['last'] . '" LIMIT 1;'));
header('Content-Type: image/jpeg'); // may need altering depending on the image format
die($r['Photo']);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>View My Blog</title>
</head>
<body>
<?php // Script 12.6 - view_blog.php
// This script retrieves blog entries from the database.
// Address error handling.
ini_set ('display_errors', 1);
error_reporting (E_ALL & ~E_NOTICE);
// Define the query.
$query = 'SELECT * FROM Authors';
if ($r = mysql_query ($query)) { // Run the query.
// Retrieve and print every record.
while ($row = mysql_fetch_array ($r)) {
print "<p><h3>{$row['First_Name']} {$row['Last_Name']}</h3>
<p>{$row['Biography']}<p/>
<img src=\"$PHP_SELF?photo&last={$row['Last_Name']}&first={$row['First_Name']}\">
<a href=\"edit_entry.php?id={$row['blog_id']}\">Edit</a>
<a href=\"delete_entry.php?id={$row['blog_id']}\">Delete</a>
</p><hr />\n";
}
} else { // Query didn't run.
die ('<p>Could not retrieve the data because: <b>' . mysql_error() . "</b>. The query was $query.</p>");
} // End of query IF.
mysql_close(); // Close the database connection.
?>
</body>
</html>
Bookmarks