fubarur Posted January 24, 2012 Share Posted January 24, 2012 So I am trying to tweak a few things on a page and I am stuck on this one. I want the ###### to also be the data in $row['id'] <?php if (file_exists('/var/www/html/images/races/######/images/' . $row['id'] . $dthumb)): ?> so if $row['id'] = 124 it would be looking for /var/www/html/images/races/124/images/124.jpg')) I know it has to be that I am stumped on the correct question to ask or search for. Any help is appreciated. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/255688-need-help-in-this-statement-please/ Share on other sites More sharing options...
premiso Posted January 24, 2012 Share Posted January 24, 2012 $row['id'] = (int)$row['id']; // cast to int to make sure nothing bad gets through. if (file_exists('/var/www/html/images/races/' . $row['id'] .'/images/' . $row['id'] . $dthumb)): Should do what you want. This is called concatenation. I also statically cast the id to an integer, as that is what you are expecting and this will make sure that something weird doesn't go through that could be used to get information about your site (more than likely not, but better save than sorry). Also, instead of manually typing the path in like that, I would use $_SERVER['DOCUMENT_ROOT'], if possible. if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/images/races/' . $row['id'] .'/images/' . $row['id'] . $dthumb)): Assuming that has been set by your webserver and it is set to /var/www/html Quote Link to comment https://forums.phpfreaks.com/topic/255688-need-help-in-this-statement-please/#findComment-1310703 Share on other sites More sharing options...
fubarur Posted January 24, 2012 Author Share Posted January 24, 2012 Thank you for your advice. That did not work for some reason but I did get this to work <?php if (file_exists('/var/www/html/images/races/' . $row['id'] . '/images/' . $row['id'] . $dthumb)): ?> Quote Link to comment https://forums.phpfreaks.com/topic/255688-need-help-in-this-statement-please/#findComment-1310709 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.