I followed a tutorial to display image from the database, this is what the table looks like in my database. What am I doing wrong?
Display
+-------+------------+----------+
| Index | Display_ID | Picture |
+-------+------------+----------+
| 1 | 12 | longblob |
+-------+------------+----------+
<?php
if (!function_exists("GetSQLValueString"))
{
function GetSQLValueString($theValue, $theType,
$theDefinedValue = "", $theNotDefinedValue = "")
{
// function definition omitted
}
}
$colname_getImage = "-1";
if (isset($_GET['image_id']))
{
$colname_getImage = $_GET['image_id'];
}
$db = mysql_connect("localhost", "root");
mysql_select_db("draftdb",$db);
$query_getImage = sprintf("SELECT mimetype, PICTURE FROM display
WHERE DISPLAY_ID = %s", GetSQLValueString($colname_getImage, "int"));
$getImage = mysql_query($query_getImage, $db) or
die(mysql_error());
$row_getImage = mysql_fetch_assoc($getImage);
$totalRows_getImage = mysql_num_rows($getImage);
mysql_free_result($getImage);
header('Content-type: image/jpeg ' . $row_getImage['mimetype']);
echo $row_getImage['image'];
?>
> <img src="show_image.php?image_id=12 <?php echo
> $row_getdetails['image_id']; ?>" alt="Image from DB" />
ERROR: > You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 2