|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
edit text files with php
I have the following example:
<?php // Places the password into the mig.cnf file in the following format // $protect['./mhtest']['mark'] = 'NLJpD6Gw6tYS2'; $cust_name = 'Harris'; $dir = 'mhtest'; $user = 'mark'; $pass = 'tikelele'; $salt = 'MG'; $passwd = crypt($pass, $salt); $path = ("\$protect['./$dir']['$user']"); $fp = fopen("hello.txt", "a+"); fwrite($fp,"//$cust_name"."\n" .$path." = "."'" .$passwd."'".";" ."\n"); fclose($fp); echo (done); ?> I am trying to use it to append this text file: <?php blah blah. blah blah. blah blah. ?> but it always appends to the bottom outside the closing php tag "?>" like this: <?php blah blah. blah blah. blah blah. ?> //Harris $protect['./mhtest']['mark'] = 'MGojrkbOSMreY'; I need it to append inside the tag like this: <?php blah blah. blah blah. blah blah. //Harris $protect['./mhtest']['mark'] = 'MGojrkbOSMreY'; ?> Who can help please? Last edited by tikelele : May 13th, 2003 at 05:49 PM. |
|
#2
|
|||
|
|||
|
PHP Code:
|
|
#3
|
|||
|
|||
|
I tried using the fseek flag that you sent--however it still appended to the end of the file.
Thank you for the input though. BTW--tell me more about the other option you suggested. |
|
#4
|
|||
|
|||
|
Sorry, I had to check the online documentation. Heh.
![]() PHP Code:
Regarding the other option, try something like this: PHP Code:
|
|
#5
|
|||
|
|||
|
i was not able to get either solution to work--it still appended to the end and I got the following error message:
Warning: REG_BADRPT:rrepetition-operator operand invalid in d:\"i am replacing the path"... on line 42 also addind SEEK_END appended at the end. any suggestions |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > edit text files with php |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|