Re: Text file (rw) question...
| From: | Rob W. | Date: | Wed, 15 Mar 2006 00:47:16 +0000 |
| Subject: | Re: Text file (rw) question... | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-41501@lists.php.net to get a copy of this message | ||
Yeah, but will that just replace the data that is present already there? I dont wanna have duplicate entries in there or i'm affraid it wont read it. The origional code you gave worked but it just ran in a big loop.
----- Original Message ----- From: "Chris" <dmagick@gmail.com>
To: "Rob W." <rob@fiberuplink.com>
Cc: <php-db@lists.php.net>
Sent: Tuesday, March 14, 2006 6:42 PM
Subject: Re: [PHP-DB] Text file (rw) question...
Rob W. wrote:Yeah, It's exactally what I needed, but I just want it to replace that one value that is sent via $_POST. What i'm trying to do is just make a web intigration to edit shoutcast .conf files. I have everything else execpt for now like I was saying, that code worked, I just want it to halt after it updates that line of code.In the simplest form: $new_textcontent = 'post_field=' . $_POST['post_field'] . "\n"; $fp = fopen($filename, 'w'); fputs($fp, $new_textcontent); fclose($fp); I'd suggest cleaning up $_POST['post_field'] before just writing it (eg making sure it is only numbers, whatever data you actually want to keep in it).----- Original Message ----- From: "Chris" <dmagick@gmail.com> To: "Rob W." <rob@fiberuplink.com> Cc: <php-db@lists.php.net> Sent: Tuesday, March 14, 2006 6:23 PM Subject: Re: [PHP-DB] Text file (rw) question...-- Postgresql & php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.phpRob W. wrote:That works, but it just throws it in to a big loop and fills up the file, any suggestions?What do you want it to do? We have absolutely no idea exactly what you're trying to achieve - that was just a guess because you're posting a form and want the new values written to a file.----- Original Message ----- From: "Chris" <dmagick@gmail.com> To: "Rob W." <rob@fiberuplink.com> Cc: <php-db@lists.php.net> Sent: Tuesday, March 14, 2006 5:54 PM Subject: Re: [PHP-DB] Text file (rw) question...-- Postgresql & php tutorials http://www.designmagick.com/Rob W. wrote:Ok, The fix is just doing something like this... list($variable, $data) = explode("=", $x); But now my problem is trying to figure out how to update that data with <form> post ect... So the main page would get MaxUser=32 It would read that info and put it in to a form field, which I have. Now I gotta get it to take and make it so that a new value can be put in that field and updated back in to the text file. I have searched all over google for about 4 hrs looking for something like this but no go, any help would be appricated.This is a simple example but it should work for you: $new_textcontent = ""; foreach($_POST as $area => $value) { $new_textcontent .= $area . "=" . $value . "\n"; } $fp = fopen($filename, 'w'); fputs($fp, $new_textcontent); fclose($fp);----- Original Message ----- From: "Dwight Altman" <dwight@multicam.com> To: "'Rob W.'" <rob@fiberuplink.com>; <php-db@lists.php.net> Sent: Tuesday, March 14, 2006 9:13 AM Subject: RE: [PHP-DB] Text file (rw) question...How about posting your solution as well? Maybe someone will find it useful. -----Original Message----- From: Rob W. [mailto:rob@fiberuplink.com] Sent: Tuesday, March 14, 2006 2:07 AM To: php-db@lists.php.net Subject: Re: [PHP-DB] Text file (rw) question... Nevermind. I figured it out. ----- Original Message ----- From: "Rob W." <rob@fiberuplink.com> To: <php-db@lists.php.net> Sent: Tuesday, March 14, 2006 1:45 AM Subject: [PHP-DB] Text file (rw) question... I'm trying to figure out how to read specific data from a text file that is already written. Example MaxUser=3D32 PortBase=3D8000 I want to be able to have php read them specific pieces of info so I can put them in to forms and update them via php. Any help would be appreciated.