Text file (rw) question...
Text file (rw) question...
am 14.03.2006 08:45:58 von Rob
------=_NextPart_000_0288_01C64709.0AD1B0B0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
I'm trying to figure out how to read specific data from a text file that
is already written. Example
MaxUser=3D3D32
PortBase=3D3D8000
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.
------=_NextPart_000_0288_01C64709.0AD1B0B0--
Re: Text file (rw) question...
am 14.03.2006 09:07:12 von Rob
Nevermind. I figured it out.
----- Original Message -----
From: "Rob W."
To:
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.
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
RE: Text file (rw) question...
am 14.03.2006 16:13:41 von Dwight Altman
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."
To:
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.
--
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Text file (rw) question...
am 15.03.2006 00:40:15 von Rob
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
Re: Text file (rw) question...
am 15.03.2006 00:54:13 von Chris
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
>
Re: Text file (rw) question...
am 15.03.2006 01:13:35 von Rob
That works, but it just throws it in to a big loop and fills up the file,
any suggestions?
----- Original Message -----
From: "Chris"
To: "Rob W."
Cc:
Sent: Tuesday, March 14, 2006 5:54 PM
Subject: Re: [PHP-DB] Text file (rw) question...
> 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
>>
Re: Text file (rw) question...
am 15.03.2006 01:19:33 von Peter Beckman
"pear install Config"
Now you can load a config file like that with a single command, load it
into an array, modify values, then write it back.
http://pear.php.net/package/Config
It is fantastic.
Beckman
On Tue, 14 Mar 2006, Rob W. wrote:
> That works, but it just throws it in to a big loop and fills up the file, any
> suggestions?
>
>
> ----- Original Message ----- From: "Chris"
> To: "Rob W."
> Cc:
> Sent: Tuesday, March 14, 2006 5:54 PM
> Subject: Re: [PHP-DB] Text file (rw) question...
>
>
>> 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
>>>
Re: Text file (rw) question...
am 15.03.2006 01:23:15 von Chris
Rob 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"
> To: "Rob W."
> Cc:
> Sent: Tuesday, March 14, 2006 5:54 PM
> Subject: Re: [PHP-DB] Text file (rw) question...
>
>
>> 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
Re: Text file (rw) question...
am 15.03.2006 01:27:32 von Rob
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.
----- Original Message -----
From: "Chris"
To: "Rob W."
Cc:
Sent: Tuesday, March 14, 2006 6:23 PM
Subject: Re: [PHP-DB] Text file (rw) question...
> Rob 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"
>> To: "Rob W."
>> Cc:
>> Sent: Tuesday, March 14, 2006 5:54 PM
>> Subject: Re: [PHP-DB] Text file (rw) question...
>>
>>
>>> 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
>>>>
Re: Text file (rw) question...
am 15.03.2006 01:42:41 von Chris
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"
> To: "Rob W."
> Cc:
> Sent: Tuesday, March 14, 2006 6:23 PM
> Subject: Re: [PHP-DB] Text file (rw) question...
>
>
>> Rob 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"
>>> To: "Rob W."
>>> Cc:
>>> Sent: Tuesday, March 14, 2006 5:54 PM
>>> Subject: Re: [PHP-DB] Text file (rw) question...
>>>
>>>
>>>> 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
Re: Text file (rw) question...
am 15.03.2006 01:47:16 von Rob
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"
To: "Rob W."
Cc:
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"
>> To: "Rob W."
>> Cc:
>> Sent: Tuesday, March 14, 2006 6:23 PM
>> Subject: Re: [PHP-DB] Text file (rw) question...
>>
>>
>>> Rob 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"
>>>> To: "Rob W."
>>>> Cc:
>>>> Sent: Tuesday, March 14, 2006 5:54 PM
>>>> Subject: Re: [PHP-DB] Text file (rw) question...
>>>>
>>>>
>>>>> 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
Re: Text file (rw) question...
am 15.03.2006 02:02:22 von Chris
Rob W. wrote:
> 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.
That particular example will replace the whole file.
If you only want to replace a particular option then that's different -
but we don't know what you are trying to do.
> ----- Original Message ----- From: "Chris"
> To: "Rob W."
> Cc:
> 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"
>>> To: "Rob W."
>>> Cc:
>>> Sent: Tuesday, March 14, 2006 6:23 PM
>>> Subject: Re: [PHP-DB] Text file (rw) question...
>>>
>>>
>>>> Rob 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"
>>>>> To: "Rob W."
>>>>> Cc:
>>>>> Sent: Tuesday, March 14, 2006 5:54 PM
>>>>> Subject: Re: [PHP-DB] Text file (rw) question...
>>>>>
>>>>>
>>>>>> 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
Re: Text file (rw) question...
am 15.03.2006 02:08:01 von Rob
So how do I make it so it just set's the variable's that are sent in the
$_POST because i wanna write it so that if the value isnt changed, it wont
send the $_POST and wont update the config file..
----- Original Message -----
From: "Chris"
To: "Rob W."
Cc:
Sent: Tuesday, March 14, 2006 7:02 PM
Subject: Re: [PHP-DB] Text file (rw) question...
> Rob W. wrote:
>> 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.
>
> That particular example will replace the whole file.
>
> If you only want to replace a particular option then that's different -
> but we don't know what you are trying to do.
>
>> ----- Original Message ----- From: "Chris"
>> To: "Rob W."
>> Cc:
>> 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"
>>>> To: "Rob W."
>>>> Cc:
>>>> Sent: Tuesday, March 14, 2006 6:23 PM
>>>> Subject: Re: [PHP-DB] Text file (rw) question...
>>>>
>>>>
>>>>> Rob 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"
>>>>>> To: "Rob W."
>>>>>> Cc:
>>>>>> Sent: Tuesday, March 14, 2006 5:54 PM
>>>>>> Subject: Re: [PHP-DB] Text file (rw) question...
>>>>>>
>>>>>>
>>>>>>> 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
Re: Text file (rw) question...
am 15.03.2006 02:14:44 von Chris
Rob W. wrote:
> So how do I make it so it just set's the variable's that are sent in the
> $_POST because i wanna write it so that if the value isnt changed, it
> wont send the $_POST and wont update the config file..
You can't stop the post because your browser does that not php (well you
could stop it with javascript).
You could store the original values in a session and then compare when
you post the new values. Take the appropriate action if they are the
same/different.
What difference does it make if you rewrite the file with the same values?
and why are you afraid of loops? That will be the easiest way to get
everything from the form.
If you only want particular values:
$newconfig = "";
$config_values = array('field1', 'field2');
foreach($config_values as $p => $fieldname) {
$newconfig .= $fieldname . '=' . $_POST[$fieldname] . "\n";
}
.....
--
Postgresql & php tutorials
http://www.designmagick.com/
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php