Hi I am having some trouble displaying images stored as a blob in a mysql database. When I run the script the image locatioon is printed out but not the image.
<?php
session_start();
ini_set( 'display_errors', '1' );
error_reporting ( 2047 );
$host="localhost"; // Host name
$username="root"; // Mysql username
$password="root"; // Mysql password
$db_name="test"; // Database name
$tbl_name="pix"; // Table name
// Connect to server and select databse.
mysql_connect("$host", "root", "root")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$myq=$_POST['myq'];
if (isset($_POST['myq'])) {
$myq = mysql_real_escape_string($_POST['myq']);
$result = mysql_query("SELECT * FROM pix WHERE title LIKE '%$myq' OR registration LIKE '%$myq'");
while ($row = mysql_fetch_array($result)) {
echo "<p>You searched for: "" . $myq . ""</p>";
echo "<table border=\"1\" align=\"center\">";
echo "<tr><th>Car Make</th>";
echo "<td>";
echo $row['title'];
echo "</td>";
echo "<tr><th>Image</th>";
echo "<td>";
echo $row["imgdata"];
echo "</td>";
echo "<tr><th>Registration</th>";
echo "<td>";
echo $row['registration'];
echo "</td>";
}
}
if (!$result) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
}
if (mysql_num_rows($result) == 0) {
echo "No records found";
exit;
}
exit();
?>