First off, unless you have a really serious reason why you have to store images directly in the database, it's generally better instead to store the images as files and just store file names in the database (it's faster and less resource-intensive).
As for your problem, skimming through the article, the place I find fread() being called comes before the database gets involved:
$data = addslashes(fread(fopen($form_data, "r"), filesize($form_data)));
Let's break that down and allow ourselves to use a few debugging techniques to diagnose matters.
$fp = fopen($form_data, "r") or die("Couldn't open file $form_data for reading.");
$data = fread($fp, filesize($form_data)) or die("Couldn't read $form_data.");
$data = addslashes($data);
From what the error message says, I'm guessing that it will die saying that it couldn't open the file properly (fopen() didn't return a suitable stream for fread() to read from).
And a question you'll need to answer for yourself: does $form_data have the value it's supposed to? And if it does, does the file it names actually exist on your machine?