Jump to content

Recommended Posts

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); 

 

}

}

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

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

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>"; 

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); 

 

}

}

 

 

 

 

 

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); 
	}
}
}
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.