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
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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.