Here's my two-penneth worth. If JS not on - problems with JS solution. WHat about file_get_contents?
The reason I suggest this is that the display of the page if using JS is at the mercy of the client's (user's) settings. The following should work regardless as it is processed on the server (although you may need full control of your php.ini file).
$file is the image to check (from DB value I take it)
if( false == ($str=@file_get_contents('$file',NULL,NULL,0,1))){
echo "<img src=\"$default_file\" ...other_attributes... />";
}else{
echo <img src=\"$file\" ...other_attributes... />";
}
The parameters for file_get_contents (0 and 1) relate to start at character 1 and read 1 character - so you're not reading the whole file - should save time - should be quick.
The '@' is required to surpress errors.
CAVEAT - if
allow_url_fopen is set to false (0) - this will not work, if you have access to your php.ini file, turn
allow_url_fopen on. The alternative would be to use cURL, but I assume this would be sloooooow.
?>
***
Linking to remote images may be asking for trouble. If this is an "avatar"/"profile" type image, perhaps it would be better if users could upload their image (which could be resized via GD2 or ImageMagick library) and the filename stored in a db.