Hey guys im new to the forumns and figured since it seems like people here are very knowledgable, i'd see if anyone might be able to help me find my error in my php code. I am pulling the images from a database and have verified they went in properly. Below is the code i used to upload the photo(which works) and the code for retreiving the image (which is broken). The photo is saved in a table named photo in a field named uploaded_photo. any advice on what i should do or something to try would be greatly appreciated.
addphoto2.php
<b> Add a Gallary</b>
<form name="form1" method = "post" enctype = "multipart/form-data">
Photographer name: <input type="text" name="authorname" size="40" /> <br />
Upload File: <input type="file" name="filename" id = "filename" size="40" /> <br />
File Type: <select name = "select">
<option value = "JPEG">JPEG</option>
<option value = "GIF">GIF</option>
<option value = "PNG">PNG</option>
<option value = "other">Other</option>
</select>
<br />
Photo Name: <input type = "text" name = "photoname" /> <br />
Photo Description: <input type = "text" name = "photodescription" />
<br />
<input type="submit" value = "submit" />
<input type="reset" value = "reset"/>
</form>
<?php
include("connect.php") ;
$authname = $_POST['authorname'];
$phototype = $_POST['select'];
$photoitself = $_POST['filename'];
$photoname = $_POST['photoname'];
$photodesc = $_POST['photodescription'];
$image = fopen($_FILES['filename']['tmp_name'],"rb");
$readimage = fread($image,$_FILES['filename']['size']);
$newimage = mysql_escape_string($readimage);
$query ="INSERT INTO photo(photo_id, photo_type, photo_name, author_name, photo_description, uploaded_photo) VALUES(' ','$phototype','$photoname','$authname', '$photodesc', '$newimage')";
$result = mysql_query($query);
the code for retreviing the images is testbrowse.php:
<?
include("imgheader.php") ;
?>
<html>
<head>
<title>Sans Titre</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<meta name="generator" content="HAPedit 3.1">
</head>
<body bgcolor="#FFFFFF">
<?php
include("connect.php");
$query = "SELECT uploaded_photo FROM photo";
$results = mysql_query($query) or die(mysql_error()) ;
// need to fetch the array to get this line to work:
$row = mysql_fetch_assoc($results);
$news = ImageCreateFromString($row['uploaded_photo']) ;
$final = imagejpeg($news);
echo $final;
?>
when calling testbrowse.php, all i get is the box with the red x inside for a broken image link. I've been searching for answers through google however after 3 days and finding nothing i figured maybe i'd ask my fellow phpers. Thanks in advance