dzhax Posted April 28, 2009 Share Posted April 28, 2009 I am making an advertisement script that can be used for multiple adverts on a single page. It uses variables to determine what image show up and where.I need it to check if an image is available and if not, then it has to re-generate a number to show one.If you need me too, I could probably try to explain it more. <?phpdo {$rndNum = mt_rand(1,2);switch($rndNum){case 1:if ($adStyle = 'vert'){ $advertImg = "_private/advert_available.png"; } else { $advertImg = ''; } $advertLink = "index.php?action=advertise"; break;case 2:if ($adStyle = 'vert'){ $advertImg = "_private/advert_available1.png"; } else { $advertImg = ''; } $advertLink = "index.php?action=advertise"; break;}}while ($advertImg = '');?> I am so used to coding visual basic 6.0 this stuff is just too different for me.Is there maybe a do until function that i could say do this until $advertImg is NOT blank? Link to comment Share on other sites More sharing options...
justsomeguy Posted April 28, 2009 Share Posted April 28, 2009 Once you have the filename, you can use the file_exists function to check if it exists.http://www.php.net/manual/en/function.file-exists.phpThis line needs 2 equal signs instead of 1:while ($advertImg = '');All of the if statements need 2 also:if ($adStyle == 'vert'){In most languages besides VB, 1 equal sign assigns a value, 2 equal signs check if something is equal. You don't want to assign a value, you want to check the value. Link to comment Share on other sites More sharing options...
dzhax Posted April 28, 2009 Author Share Posted April 28, 2009 how would i use the file_exists thing?and i changed the = to ==----ahh nvm it works... thanks Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.