Jump to content

Need help in this statement, please


Recommended Posts

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']


if (file_exists('/var/www/html/images/races/######/images/' . $row['id'] . $dthumb)):


so if $row['id'] = 124 it would be looking for




I know it has to be that I am stumped on the correct question to ask or search for.


Any help is appreciated.



Link to comment
Share on other sites

 $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

Link to comment
Share on other sites


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.