returning blob from mysql database using php
Posted: Sun Dec 07, 2008 9:00 pm
I'm trying to figure out how to return a blob image that's stored in a table in my mysql database.
here is my code:
<?php
$DBConnect = mysqli_connect("localhost", "root", "newpwd", "portfolio")
Or die("<p>Connection failed dude!</p>");
$SQLString = "SELECT * FROM projects";
$QueryResult = mysqli_query($DBConnect, $SQLString);
echo "<table width='10%' border='1'>";
echo "<tr><th>Project</th><th>Description</th><th>Link</th></tr>";
$Row = mysqli_fetch_row($QueryResult);
do {
//display proj_id, proj_desc
echo "<tr><td>{$Row[0]}<td>{$Row[1]}</td>";
//display proj_img
$id = $_GET['id'];
$query = mysql_query("SELECT port_img FROM projects WHERE id='".$id."'");
$row = mysql_fetch_array($query);
$content = $row['image'];
header('Content-type: image/jpg');
echo "<td>$Content;</td></tr>";
$Row = mysqli_fetch_row($QueryResult);
} while ($Row);
mysqli_close($DBConnect);
echo "</table>";
?>
Can anyone help me figure this out?
Thanks.
here is my code:
<?php
$DBConnect = mysqli_connect("localhost", "root", "newpwd", "portfolio")
Or die("<p>Connection failed dude!</p>");
$SQLString = "SELECT * FROM projects";
$QueryResult = mysqli_query($DBConnect, $SQLString);
echo "<table width='10%' border='1'>";
echo "<tr><th>Project</th><th>Description</th><th>Link</th></tr>";
$Row = mysqli_fetch_row($QueryResult);
do {
//display proj_id, proj_desc
echo "<tr><td>{$Row[0]}<td>{$Row[1]}</td>";
//display proj_img
$id = $_GET['id'];
$query = mysql_query("SELECT port_img FROM projects WHERE id='".$id."'");
$row = mysql_fetch_array($query);
$content = $row['image'];
header('Content-type: image/jpg');
echo "<td>$Content;</td></tr>";
$Row = mysqli_fetch_row($QueryResult);
} while ($Row);
mysqli_close($DBConnect);
echo "</table>";
?>
Can anyone help me figure this out?
Thanks.