Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

function help

Status
Not open for further replies.

kpdvx

Programmer
Joined
Dec 1, 2001
Messages
87
Location
US
function userphoto($uid) {
$query = "SELECT photo FROM profiles WHERE userid = '$uid'";
$result = mysql_query($query);
@extract(mysql_fetch_array($result));

if ($photo != "") {
$photo_filename = $photo;

} elseif ($photo == "") {
$photo_filename = 'default.gif';

}

return $photo_filename;
}

$photo_filename has no value. Any idea why?
 
Is the photo field in the database blank?
 
$photo is a field in the profiles table. It is assigned to $photo when I extract it. Yes, it is blank. If the field is blank, then I want $photo_filename = 'default.gif', and if it has a value, then I want $photo_filename to be equal to that value, like say, 'picture.jpg'.
 
NOT NULL, so blank.
 
Well, you could simply change the
Code:
    } elseif ($photo == "") {
line with
Code:
    } else {
//Daniel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top