mjgdunne Posted April 21, 2008 Share Posted April 21, 2008 Hi I am having trouble displaying images stored in a mysql database, when i run the script all i am getting is the location path to the image, is there any way of displaying the images, here is my my code: <?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(); ?> Link to comment https://forums.phpfreaks.com/topic/102111-problem-displaying-images-from-mysql-database/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.