Hello,
for me a very strange error,
I have a "ini" file. With a PHP script I show the entries and can edit and save them.
I do the editing with this function.
function edit_ini($ini_file, $what, $replace){
$fp = fopen($ini_file, "r");//open file
$contents = fread($fp, filesize($ini_file));
fclose($fp);
$new_contents = ereg_replace($what, $replace, $contents);
$fp = fopen($ini_file, "w");
fwrite($fp, $new_contents);
fclose($fp);
}
For changing "AddressField1;
edit_ini($inifile, "AddressField1=$anzeige1", "AddressField1=$_POST[StcAddressField1]\r\n");
The first time I call the script, all changes will be done, but at the end of the ini file, some lines will be deleted.
This ist the end of the original ini file,
...
[Client]
Retries=2
TimeOut=10
Coding=1
Bytes=4
Count=32
[Host]
Entry=
After the first call of the function, the entries will be changed but at the end of the ini file this lines will be deleted,
[Host]
Entry=
The next time of calling the function or the script the end of the ini file looks like,
[Client]
Retries=2
TimeOut=10
Coding=1
Bytes=4
Co
The same with "str_replace()"
I have no idea why this happens?
Is there a better way to change the entries of the ini file?
regards
hjcarlo