file_put_contents function write a .txt is not complete

Hi guys,

After i read the source file (COUNTRY.TXT) and made some changed, then use the function file_put_contents() and save a new file (updateCountry.txt) , getting error message “Notice: Undefined offset: 5999 in C:\wamp\www\WebForm\July\SaveRoute.php on line [color=red]28[/color]”

P.S line 28 code = $totalparts[0][“desc”][$i]." ".PHP_EOL;

and i checked around 25-30% data wrote in the updateCountry.txt, other 70-75% didn’t !

Please help, thanks.

[php]

<?php $count=count($_POST['country']); $filehandel="updateCountry.txt"; //clean up the file file_put_contents($filehandel, ""); $totalparts[]=array("country"=>$_POST['country'], "zone"=>$_POST['zone'], "carrier"=>$_POST['carrier'], "lengthD"=>$_POST['lengthD'], "desc"=>$_POST['desc']); for($i=0;$i<$count;$i++) { $line= $totalparts[0]["country"][$i]." ". $totalparts[0]["zone"][$i]." ". $totalparts[0]["carrier"][$i]." ". $totalparts[0]["lengthD"][$i]." ". $totalparts[0]["desc"][$i]." ".PHP_EOL; file_put_contents($filehandel, $line, FILE_APPEND); } ?>

[/php]

Brgds/Brandon Chau

Hi all,

just to provide more information

when i echo $count=count($_POST[‘country’]);
it shows 6000
but it supposed had 27691 records , it seem didn’t pass all the data(with $_POST) to this page.

is any limitation of multi dimension array or $_POST ?

Thank you all.

Brgds/Brandon Chau

For a large write process, you may be more apt to use fwrite()

Hi astonecipher,

Thanks for your reply ^^"

I think the root cause seem related to the $_POST[“desc”]

Actually , i’m using a form (update.php) to pass some input text value(array) to save.php, and then save those arrays in a txt file,

but the data isn’t post completely , as i mentioned, i supposed $_POST[“desc”] should include 27691 records,

but when i use var_dump to check, it just had 6000 records . Btw , update.php codes as below, thanks.

[php]
echo “”;

echo"

";

foreach ($totalparts as $key => $value)
{
echo"

";
echo “”;
echo “”;
echo “”;
echo “”;
echo “”;
echo “”;
}
echo"
";
echo “”;
[/php]

Hi all,

I just fixed that issues, thanks.

Solution:

Increased the value for max_input_vars in php.ini

in this case i increased to 300000 => max_input_vars = 300000;

Brgds/Brandon Chau

Sponsor our Newsletter | Privacy Policy | Terms of Service