Q:

How do I get PHP to display a user picture if you have one within a blog post?

I have a script that can disply user pictures but I want to have it now so if you don't have a picture it displays a default one.
CODE
if (file_exists($displayuserimage)) {
    $displayuserimage =  '<img src="upic/'. $posts['userid'].'.jpg" width="50px" height="50px" border="2"  />';
} else {
    $displayuserimage =  '<img src="upic/default.jpg" width="50px" height="50px" border="2"/>'; 
}

That's what im guessing, but this is the working script, that shows images if you have one:
$displayuserimage = '<img src="upic/'. $posts['userid'].'.jpg" width="50px" height="50px" border="2"/>';

A:

Your if is checking a variable,$displayuserimage, which has not been defined before. To check if your image exists, that if may look like
if (file_exists("upic/". $posts['userid'].".jpg")) {

