The error is in the next line, I am an ex-VB programmer, and I use <> instead of !=, it works anyway! (try it yourself).
If the field $row[13]; is not null it means there is a picture for that register in the DataBase.
The error is in this line:
$textwidth = (630-$pic_width);
if instead of typing $textwidth = (630-$pic_width) i type $textwidth = 500; it works fine!!
Any hints?