Jump to content

HELP :) if ($pic ==0)


rocoso

Recommended Posts

Im generating some xml...  the script is working fine except if the userid does not exist in the table. I want it to use the default nopic.gif.  This seems simple but i cant get it to work :(

$query = "SELECT pic_name FROM album WHERE user_id='".$userid."' ORDER BY RAND() DESC LIMIT 12";
$result = mysql_query($query);

ECHO <<<END
<?xml version='1.0' encoding='UTF-8'?>
<galeria>
    
END;

for ($i = 0; $i < mysql_num_rows($result); $i++) {

@$row = mysql_fetch_row($result);
$picture = "userpictures/".($row["pic_name"]);

if ($row["pic_name"] == 0){              <---  this part is not working  arhhh
$picture = "userpictures/no-pic.gif";   
}
ECHO <<<END

<fotos gde="$picture"  />


END;
}
ECHO <<<END
</galleria>
END;
?>

Link to comment
https://forums.phpfreaks.com/topic/78142-help-if-pic-0/
Share on other sites

It would if it was in the right place.  In front of the Variable isn't the right place.

 

The @ sign simply stops something to do with sql error thing. Um try puttin an else clause in there which echos something to the browser it might be a logical error to do with it not actully == 0.

Link to comment
https://forums.phpfreaks.com/topic/78142-help-if-pic-0/#findComment-395564
Share on other sites

It would if it was in the right place.  In front of the Variable isn't the right place.

 

The @ sign simply stops something to do with sql error thing. Um try puttin an else clause in there which echos something to the browser it might be a logical error to do with it not actully == 0.

 

yes ofcourse

 

$row = @mysql_fetch_row($result);

 

That is correct way I believe correct me if im wrong

?

Link to comment
https://forums.phpfreaks.com/topic/78142-help-if-pic-0/#findComment-395587
Share on other sites

first things first...I don't think you have a userid that does not exists...

 

the script is working fine except if the userid does not exist in the table. I want it to use the default nopic.gif. 

 

$query = "SELECT pic_name FROM album WHERE user_id='".$userid."' ORDER BY RAND() DESC LIMIT 12";

 

This line would select 12 records with that userid on your db.  Hence userid does exist.

Link to comment
https://forums.phpfreaks.com/topic/78142-help-if-pic-0/#findComment-395629
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.