I created forms to insert images and retrieve it from the mysql db. I can see the images in the database, but when i run the showimage script on my website, it shows only placeholders without showing the images. Please what should i do. Below is my showimage.php script:
Code:
.........
<?php require_once('../Connections/connportal.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$colname_rs = "-1";
if (isset($_GET['id'])) {
$colname_rs = $_GET['id'];
}
mysql_select_db($database_connection, $connportal);
$query_rs = sprintf("SELECT * FROM tbl_images WHERE id = %s", GetSQLValueString($colname_rs, "int"));
$rs = mysql_query($query_rs, $connportal) or die(mysql_error());
$row_rs = mysql_fetch_assoc($rs);
$totalRows_rs = mysql_num_rows($rs);
header("Content-Type:image/jpeg");
echo $row_rs["image"];
mysql_free_result($rs);
?>