I've been working on my project since 1:30 pm (it is now 2 am!) and I'm very tired. I'm obviously not understanding something here, so I'm hoping a second pair of eyes can see what I'm doing wrong. I'm storing an image (along with other data) per record in a table. Users browse their hard drive to select the image they want to upload when they click the submit button using the "Browse" button. Here is snippet code from the form:
<pre>
<form method="post" action="<?=$PHP_SELF; ?>" enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="1000000">
.
.
.
<input name="petfile" type="file" size="40">
.
.
.
</form>
</pre>
Upon Submit, I open and read the file, store it, and get the file type:
<pre>
$petdata = addslashes(fread(fopen($petfile, "r"), filesize($petfile)));
$filetype = $petfile_type;
</pre>
I then use this new variable to update/add the record to the database. (Yes, column "petpic" is a blob.):
<pre>
UPDATE pet SET petpic = '$petdata' WHERE petid = '$petid';
</pre>
When the page posts to itself, I want the image to display on the page, so I requery the database for the updated informatin and setup the following HTML tags to display the picture:
<pre>
<img src="<?=$petpic; ?>">
</pre>
This is where my problem comes in. Instead of getting a picture displayed on the page, I get a whole screens worth of garbage in my code and then my form will begin after that. I tried setting the header, but then I get an error saying that the header information has already been sent.
I would be so grateful for any guidance I can receive!