rocoso Posted November 20, 2007 Share Posted November 20, 2007 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; ?> Quote Link to comment Share on other sites More sharing options...
revraz Posted November 20, 2007 Share Posted November 20, 2007 Looks like you have a @ at the wrong place @$row = mysql_fetch_row($result); Quote Link to comment Share on other sites More sharing options...
rocoso Posted November 21, 2007 Author Share Posted November 21, 2007 yes i removed that. Script still works. Quote Link to comment Share on other sites More sharing options...
zolen Posted November 21, 2007 Share Posted November 21, 2007 try if ($pic =='') or if(is_null($pic)) Im not a guru .. its just what I would try Quote Link to comment Share on other sites More sharing options...
Distant_storm Posted November 21, 2007 Share Posted November 21, 2007 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. Quote Link to comment Share on other sites More sharing options...
teng84 Posted November 21, 2007 Share Posted November 21, 2007 this condition if ($row["pic_name"] == 0) sound like your default value in your Db if you dont have an image stored is 0 is that right? Quote Link to comment Share on other sites More sharing options...
revraz Posted November 21, 2007 Share Posted November 21, 2007 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. Quote Link to comment Share on other sites More sharing options...
Distant_storm Posted November 21, 2007 Share Posted November 21, 2007 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 ? Quote Link to comment Share on other sites More sharing options...
wsantos Posted November 21, 2007 Share Posted November 21, 2007 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.