Help with fwrite

Hello im back,
today i need help for php programing…
First i will say you what i want and second i will show you my script to see whats error inside
---------------Description---------------
i have one ini file, one form and php form action. When someone type in form “number” ex. 1000, script is adding(or minus) this value in ini file.
Ex.
ini looks:
name=bojmaliev
money=10000
level=10
And after form submited with number inside 1000 ini looks:
ini looks:
name=bojmaliev
money=11000
level=10
---------------My script---------------
[php]

Donate:
<?php $user = parse_ini_file("user.ini"); $org = parse_ini_file("org.ini"); $user1 = $user['money']; $org2 = $org['org_money']; if (isset($_POST['donater'])){ $submitdonate = $_POST['donate']; function minus($usermoney, $donate){ $afterusermoney = $usermoney - $donate; return $afterusermoney; } function add($orgmoney, $donate){ $afterorgmoney = $orgmoney + $donate; return $afterorgmoney; } $file1 = fopen("user.ini", "w"); fwrite($user['money'], (minus($user1, $submitdonate))); fclose($file1); } ?> [/php] The problem in my script is: When the form is submited script get the money from the file, then the money are minused from the value from form, and after my user.ini file looks just the minused value, all other is deleted

Thats all
thanks in advance
Bojmaliev :slight_smile:

Where is this assigned a value ?
[php]$user[‘money’];[/php]

Sorry did not see the parse_ini_file function.

Maybe you want to append to file rather than write ?

[php]$file1 = fopen(“user.ini”, “w+”);[/php]
or depends how you want the file to add data
[php]
file1 = fopen(“user.ini”, “a”);
file1 = fopen(“user.ini”, “a+”);
[/php]

no, i dont want to write to end of the file, i want to write in money=“Here” and after to appear just new added, not old, old to be deleted–
Sorry in my script there is $user[‘money’] i think there was $file1

:slight_smile:
and on the start of my file i have parse ini function

Sponsor our Newsletter | Privacy Policy | Terms of Service