Tips for Building Web Database Applications with PHP and MySQL
Subject:   make this work on XP/PHP4.2.3
Date:   2004-01-07 02:28:49
From:   emdeboas
Thanks for the good article!
It helped me to finally solve the problem "how to get images into MySQL using PHP",
that I was staring at for a week now, searching all over the web for working examples.
Seeing yours working online made me looking better at why it was not working on my local PC.
I already decided to go write this in Java instead, but I will probably spare myself the trouble now.
Next time I walk into a suitable bookshop, I will consider buying the book.

That said, I needed to make a few changes to make the example work. The code worked fine unchanged on
my website running Linux/PHP4.1.2, but not on my laptop, running XP/PHP4.2.3. The php.ini files
look very similar on both.

1. It seems that you cannot read uploaded files, you have to move them first:
// if (is_uploaded_file($userfile)) ... replaced by:
// Was a file uploaded?
$uploaddir = 'c:/phpdev/uploads/';
$uploadfile = $uploaddir . $_FILES['userfile']['name'];

if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile))

2. My jpegs seem to have mime-type image/pjpeg, that is not recognized.

3. On windows you need to read files in binary mode, otherwise the upload looks ok,
but the database contains only part of the file:
$file = fopen($uploadfile, "rb");

4. Register_globals needs to be "On" in php.ini

5. This does not work (gives compile error in Eclipse with PHP plugin) in view.php:
header("Content-Type: {$data["mimeType"]}");
obviously a quote prblem.

6. Similar problem in receipt.php (twice):
<td><?php echo "{$row["shortName"]}";?></td>

After having made these fixes, it works on my laptop too, and I can start adding EXIF and IPTC functionality now.
Thanks again.

1 to 1 of 1
1 to 1 of 1