idiotstrike Posted December 16, 2010 Share Posted December 16, 2010 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 More sharing options...
phpretard Posted December 16, 2010 Share Posted December 16, 2010 $file = fopen("T:/hns/cstrike/mapcycle.txt", "r"); shouldn't this be: $file = fopen("T:\hns\cstrike\mapcycle.txt", "r"); I think local drives have backslashes instead of forward. Link to comment https://forums.phpfreaks.com/topic/221864-read_file-returns-false-for-no-reason/#findComment-1148094 Share on other sites More sharing options...
idiotstrike Posted December 16, 2010 Author Share Posted December 16, 2010 Afaik the slashes should be \\ or /. Btw: Sorry for the thread name, it should be file_exists(). Dunno what I was thinking about. Link to comment https://forums.phpfreaks.com/topic/221864-read_file-returns-false-for-no-reason/#findComment-1148095 Share on other sites More sharing options...
phpretard Posted December 16, 2010 Share Posted December 16, 2010 I have to use "G:\Documents" on my server... Link to comment https://forums.phpfreaks.com/topic/221864-read_file-returns-false-for-no-reason/#findComment-1148097 Share on other sites More sharing options...
idiotstrike Posted December 16, 2010 Author Share Posted December 16, 2010 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(). Link to comment https://forums.phpfreaks.com/topic/221864-read_file-returns-false-for-no-reason/#findComment-1148098 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.