Jump to content

read_file() returns false for no reason


idiotstrike

Recommended Posts

Hello all. I have this code:

<?php

echo '
<br><br>
<center>
<table border="1" cellspacing="0" cellpadding="0" width="540">
<tr> 
<th bgcolor="3a3a3a" align="center"><font face="Arial, Helvetica, sans-serif" size="2">  Název mapy  </font></th>
<th bgcolor="3a3a3a" align="center"><font face="Arial, Helvetica, sans-serif" size="2"> Download </font></th>
<th bgcolor="3a3a3a" align="center"><font face="Arial, Helvetica, sans-serif" size="2"> Screenshot </font></th>
</tr>';

$file = fopen("T:/hns/cstrike/mapcycle.txt", "r");
while (($buffer = fgets($file, 4096)) != false)
{
   
if(file_exists("maps/".$buffer.".zip"))
	$download = "<a href='http://www.traxxzone.cz/maps/".$buffer.".zip'>Download</a>";
else
	$download = "---";

if(file_exists("maps/screenshots/".$buffer.".jpg"))
	$screen = "<a href='http://www.traxxzone.cz/maps/screenshots/".$buffer.".jpg'>Screenshot</a>";
else
	$screen = "---";

echo "<tr><th>".$buffer."</th><th>".$download."</th><th>".$screen."</th></tr>";
}
echo "</table></center>";
fclose($file);
?>

 

That should print out all maps listed in mapcycle.txt (counter-strike server) and if the mapname exists in maps/map_name.zip, then there is a download link. However it doesn't work as should. Map name is always true in first TH, no problems with that. However the link is all the time only on the last row (even if I change the map order in mapcycle.txt). Can anybody help me?

 

Edit: And for the screenshots, there aren't any now, so I can't check.

Link to comment
https://forums.phpfreaks.com/topic/221864-read_file-returns-false-for-no-reason/
Share on other sites

On the Windows platform, be careful to escape any backslashes used in the path to the file, or use forward slashes.

 

http://cz.php.net/manual/en/function.fopen.php

 

Anyway the file is opened successfully, the problem comes from file_exists().

Archived

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.