eronmezza Posted August 28, 2007 Share Posted August 28, 2007 here's the code: not even the echo 'TILLÁROMHAJJ' part works. please somebody find that little bug that must be somewhere in because i cant solve it for about a week now and it kinda pisses me off. ??? if (!isset($_POST['submit'])) { } else { $lines = count(file($filename)); if ($lines < 30 ) { $filetartalom = fopen($filename,"a+"); fwrite($filetartalom, $output); # $mappa = "versenyfajlok"; # # # if (!is_dir($mappa)) { # print "Nincs ilyen mappa."; # } # # else { # # # $open_dir = opendir($mappa); # # foreach(glob("verseny*.txt") as $filenameek){ # $beolvasas = fopen($filenameek, 'r'); # $beolvasott = file_get_contents($filenameek); # echo "$beolvasott"; # } # # # echo "TILLÁROM HAJJ"; # # fclose($filenameek); # # # # # } # else { echo "megtelt!" ; } # closedir($open_dir); } } Quote Link to comment https://forums.phpfreaks.com/topic/67008-solved-php-fgets-doesnt-work-anything-i-do/ Share on other sites More sharing options...
ReDucTor Posted August 28, 2007 Share Posted August 28, 2007 Ok then first things first # is a comment, thats why the rest of the code is not executing. The second thing your using fopen() with out any other file operation functions which require a file pointer, file_get_contents() does not need a file pointer, it works with a file name, and fclose() is being used with a filename so this will not work, even though its not needed if you remove the fopen() if (!isset($_POST['submit'])) { } else { why not if (isset($_POST['submit'])) { Also its not important, but you can eliminate the dir loop down to foreach(glob("verseny*.txt") as $filename) readfile($filename); That outputs all files that start with verseny Quote Link to comment https://forums.phpfreaks.com/topic/67008-solved-php-fgets-doesnt-work-anything-i-do/#findComment-336006 Share on other sites More sharing options...
eronmezza Posted August 28, 2007 Author Share Posted August 28, 2007 okay it's working just a few questions: 1)it doesnt echo the contents of the files in that dircetory that i pointed to, it echoes the files in the root directory and where the .php file is. how should i point to the directory? 2) how do i put line breaks into the printed text...? now it prints all the text into one line Quote Link to comment https://forums.phpfreaks.com/topic/67008-solved-php-fgets-doesnt-work-anything-i-do/#findComment-336113 Share on other sites More sharing options...
MadTechie Posted August 28, 2007 Share Posted August 28, 2007 okay it's working just a few questions: 1)it doesnt echo the contents of the files in that dircetory that i pointed to, it echoes the files in the root directory and where the .php file is. how should i point to the directory? set $mappa to the folder you wish to use 2) how do i put line breaks into the printed text...? now it prints all the text into one line add <br> ie echo "TILLÁROM HAJJ<br>"; Quote Link to comment https://forums.phpfreaks.com/topic/67008-solved-php-fgets-doesnt-work-anything-i-do/#findComment-336120 Share on other sites More sharing options...
eronmezza Posted August 28, 2007 Author Share Posted August 28, 2007 set $mappa to the folder you wish to use actually it is is set like $mappa = "../versenyfajlok/"; and i also tried $mappa = "versenyfajlok"; none works... Quote Link to comment https://forums.phpfreaks.com/topic/67008-solved-php-fgets-doesnt-work-anything-i-do/#findComment-336124 Share on other sites More sharing options...
MadTechie Posted August 28, 2007 Share Posted August 28, 2007 i assume $open_dir = opendir($mappa); isn't comment out Quote Link to comment https://forums.phpfreaks.com/topic/67008-solved-php-fgets-doesnt-work-anything-i-do/#findComment-336128 Share on other sites More sharing options...
eronmezza Posted August 28, 2007 Author Share Posted August 28, 2007 what do you mean isnt comment out....? Quote Link to comment https://forums.phpfreaks.com/topic/67008-solved-php-fgets-doesnt-work-anything-i-do/#findComment-336133 Share on other sites More sharing options...
MadTechie Posted August 28, 2007 Share Posted August 28, 2007 can you post your latest code please Quote Link to comment https://forums.phpfreaks.com/topic/67008-solved-php-fgets-doesnt-work-anything-i-do/#findComment-336134 Share on other sites More sharing options...
eronmezza Posted August 28, 2007 Author Share Posted August 28, 2007 if (!isset($_POST['submit'])) { } else { $lines = count(file($filename)); if ($lines < 100 ) { if (!is_file($filename)) { $filetartalom = fopen($filename,"a+"); fwrite ($filetartalom, "----------" . $_POST['Idopont'] . "-----------\r\n"); } fwrite($fileellen, $output); $mappa = "../versenyfajlok/"; if (!is_dir($mappa)) { print "Nincs ilyen mappa."; } else { $open_dir = opendir($mappa); $sortores = 1; foreach(glob("verseny*.txt") as $filenameek){ $beolvasott = file_get_contents($filenameek); if ($sortores == 1) { $beolvasott = nl2br($beolvasott); } echo "$beolvasott"; } if ($sortores == 1) { $beolvasott = nl2br($beolvasott); } } closedir($open_dir); } } Quote Link to comment https://forums.phpfreaks.com/topic/67008-solved-php-fgets-doesnt-work-anything-i-do/#findComment-336147 Share on other sites More sharing options...
MadTechie Posted August 28, 2007 Share Posted August 28, 2007 try this <?php if (isset($_POST['submit'])) { $lines = count(file($filename)); if ($lines < 100 ) { if (!is_file($filename)) { $filetartalom = fopen($filename,"a+"); fwrite ($filetartalom, "----------" . $_POST['Idopont'] . "-----------\r\n"); } fwrite($fileellen, $output); $mappa = "../versenyfajlok/"; if (!is_dir($mappa)) { print "Nincs ilyen mappa."; }else{ chdir($mappa); $open_dir = opendir($mappa); if($open_dir === false){die("Invalid mappa '$mappa'<br>")} $sortores = 1; foreach(glob("verseny*.txt") as $filenameek) { $beolvasott = file_get_contents($filenameek); if ($sortores == 1) { $beolvasott = nl2br($beolvasott); } echo "$beolvasott<br>"; } if ($sortores == 1) { $beolvasott = nl2br($beolvasott); } closedir($open_dir); } } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/67008-solved-php-fgets-doesnt-work-anything-i-do/#findComment-336163 Share on other sites More sharing options...
eronmezza Posted August 28, 2007 Author Share Posted August 28, 2007 thanks for help! so mainly you put an chdir($mappa); lline in? and what's that double line break stuff..? Quote Link to comment https://forums.phpfreaks.com/topic/67008-solved-php-fgets-doesnt-work-anything-i-do/#findComment-336166 Share on other sites More sharing options...
MadTechie Posted August 28, 2007 Share Posted August 28, 2007 Also moved closedir($open_dir); up and added a check if($open_dir === false){die("Invalid mappa '$mappa'<br>")} to add a break you would echo "<br>"; Quote Link to comment https://forums.phpfreaks.com/topic/67008-solved-php-fgets-doesnt-work-anything-i-do/#findComment-336167 Share on other sites More sharing options...
eronmezza Posted August 28, 2007 Author Share Posted August 28, 2007 thanks a million mate... problem solved really you dont know how f**ing annoying this script got and all the geeks on the net could be as nice to say im a lame that i cant do that... thanks again! Quote Link to comment https://forums.phpfreaks.com/topic/67008-solved-php-fgets-doesnt-work-anything-i-do/#findComment-336179 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.