I have successfully uploaded image to mysql database using a form: This is the code:
<?php
$errmsg = "";
if (! @mysql_connect("localhost","root","")) {
$errmsg = "Cannot connect to database";
}
@mysql_select_db("adim");
if(isset($_REQUEST))
{
$imgtype=$_FILES;
$name=$_REQUEST;
$address=$_REQUEST;
$dateofbirth=$_REQUEST;
if($imgtype=="image/jpeg" || $imgtype=="image/jpg" || $imgtype=="image/pjpeg" || $imgtype=="image/gif" || $imgtype=="image/x-png" || $imgtype=="image/bmp")
{
$image=$_FILES;
$fp = fopen($image, 'r');
$content = fread($fp, filesize($image));
$content = addslashes($content);
fclose($fp);
$sql="insert into img_tab1 (name,image,address,dateofbirth) values ('$name','$content','$address','$dateofbirth')";
$res=mysql_query($sql) or die (mysql_error());
}
}
?>
Now I need to display the row data including the image, can someone please offer a code that will solve the problem.
Thanks
Austin