Hello I am having some problems with these to functions
here it is

			<?
			if ($game == "HL") {
			$map = $gameinfo->serverinfo["map"];
			if (file_exists(getcwd()."/images/maps/Half-Life/" . $map . ".jpg")) {
					echo "<td rowspan=\"5\"><img src=\"images/maps/Half-Life/" . $map . ".jpg\"></td>";
				}
				else {
					echo "<td rowspan=\"5\"><img src=\"images/maps/Half-Life/map.jpg\" ></td>";
				}
			}
			?>

what it does is always return false and echo the "else" code now if i change $map in the if statment to a filename by hand it will work and echo the image out any ideas i know its not PHP because i use file_exists on the same server on the main page of my site
I also get the same problem if i use is_file

Thanks
Don Gordon

    Try this:

    <? 
                if ($game == "HL") { 
                $map = $gameinfo->serverinfo["map"]; 
                if (file_exists(getcwd()."/images/maps/Half-Life/$map.jpg")) { 
                        echo "<td rowspan=\"5\"><img src=\"images/maps/Half-Life/" . $map . ".jpg\"></td>"; 
                    } 
                    else { 
                        echo "<td rowspan=\"5\"><img src=\"images/maps/Half-Life/map.jpg\" ></td>"; 
                    } 
                } 
                ?>
    

    See if that works.

      Try this:

      <?  
      $dir = getcwd();
      if ($game == "HL") {
      $map = $gameinfo->serverinfo["map"];
      if (file_exists($dir/images/maps/Half-Life/$map.jpg")) {
      echo "<td rowspan=\"5\"><img src=\"images/maps/Half-Life/$map.jpg\"></td>";
      }
      else {
      echo "<td rowspan=\"5\"><img src=\"images/maps/Half-Life/map.jpg\" ></td>";
      }
      }
      ?>

        Why not just use
        "./images/maps/Half-Life/$map.jpg"

        are you sure the images dir is in the current dir?

        HalfaBee

          99.9% chance that the problem is $map not containing the value you expect it to be. So, print your line that uses it:

          <?php 
          echo getcwd()."/images/maps/Half-Life/" . $map . ".jpg";
          ?>
          

          And compare it to what you use when it works.

          On an unrelated note, consider using 'single quotes' so you don't have to needlessly escape all the " with .

            Still not working i Dont get this

            i am now using this code

            			if ($game == "HL") {
            				chdir("C:/home/clan/images/maps/HL/");
            				$file = $gameinfo->serverinfo['map'];
            				$file .= ".jpg";
            				if (is_file($file)) {
            					echo "<td rowspan=\"5\"><img src=\"images/maps/HL/$file\"></td>";
            				}
            				else {
            					echo "<td rowspan=\"5\"><img src=\"images/maps/HL/map.jpg\" ></td>";
            				}
            			}
            

            that still outputs the same thing i guess i should mention the path to this file

            C:/home/clan/ - file
            C:/home/clan/images/maps/HL/ - images

            also i have tried the echo thing and i can copy the output and put it in explorer and it will open the image

            Thank You

              Your on a Windoze host, you have to use \ instead of /.
              If your string is in " use \ if your string is in ' use .

              HalfaBee

                I have tried that and i should metion that i have never needed to use \ on windows maby on windows 98 or ME but 2000 and XP i have always been able to us /

                  Got it working. I guess there was something at the end of the string because i notices that when i was trying to use fopne("stuff". $map .".jpg") i would get the error cant find stuff/2fort with no ext so out a trim in and it worked

                  			if ($game == "HL") {
                  				if (is_file("./images/maps/HL/" . trim($gameinfo->serverinfo['map']) . ".jpg")) { //fopen($map, "r")
                  					echo "<td rowspan=\"5\"><img src=\"images/maps/HL/" . trim($gameinfo->serverinfo['map']) . ".jpg\"></td>";
                  				}
                  				else {
                  					echo "<td rowspan=\"5\"><img src=\"images/maps/HL/map.jpg\" ></td>";
                  				}
                  			}
                  
                    Write a Reply...