Gotya. The why not limit your include file to only contain those values that
are important to you. So you get something like:

varsdatabase.inc

$dbhost="xxxxx";
$dbuser="yyyyy";
$dbpass="zzzzz";

Then, in your PHP code you just rewrite this simple file. That way you don't
have to worry about parsing files etc... Just delete the existing
varsdatabase.inc and build a new one from scratch. It's no longer difficult
because it's only 3 lines long.




> > > $dbhost='localhost';

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: 20 March 2001 14:26
To: Neil Kimber; Stewart Taylor; [EMAIL PROTECTED]
Subject: Re: [PHP] Editing Variables from another script.


Basically, thats not what I'm going to do.

I'm making an administrative script such that admins can change the location
and values of the $dbhost, $dbuser, $dbpass in the database.inc with just a
form.

Kinda tough eh ?

----- Original Message -----
From: "Neil Kimber" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; "Stewart Taylor"
<[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Tuesday, March 20, 2001 10:25 PM
Subject: RE: [PHP] Editing Variables from another script.


> It depends upon what your overall aim actually is.
>
> If you want a different value depending upon where this file is being used
> in your site, then you should probably just set the value accordingly in
> that part of the site.
> i.e.
> > > include "database.inc"
> > > .
> > > .
> > > .
> > > .
> > > $dbhost='localhost';
>
> If you want a different value in the same place based upon a different
> 'user' or other criteria, then you should probably write some logic to
> handle the situation.
> i.e.
>
> include "database.inc";
>
> if (MYCRITERIA)
> {
> $dbhost='localhost';
> }
>
> The only reason that I can think of for you wanting to change the physical
> file would be if you are writing some code to generate a release for
> different users. In which case, you'll probably want to build a parser and
> use some kind of templating system.
>
> Neil
>
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: 20 March 2001 14:08
> To: Neil Kimber; Stewart Taylor; [EMAIL PROTECTED]
> Subject: Re: [PHP] Editing Variables from another script.
>
>
> What other ways might there be ?
>
>
> ----- Original Message -----
> From: "Neil Kimber" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>; "Stewart Taylor"
> <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
> Sent: Tuesday, March 20, 2001 6:10 PM
> Subject: RE: [PHP] Editing Variables from another script.
>
>
> > Do you mean that you want to alter the physical contents of
> 'database.inc'?
> > This would require you parsing the existing file yourself, writing a new
> > version of the file, altering the relevant line of code, removing the
> > original file and renaming your new file to the original filename.
> >
> > This isn't a good approach, are you sure there isn't a different way for
> you
> > acheive your aims?
> >
> > -----Original Message-----
> > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> > Sent: 20 March 2001 10:02
> > To: Stewart Taylor; [EMAIL PROTECTED]
> > Subject: Re: [PHP] Editing Variables from another script.
> >
> >
> > I think you didn't get what I meant,
> >
> > I need a script such that I can change the content of database.inc from
an
> > external script (form or whatever)
> >
> >
> > ----- Original Message -----
> > From: "Stewart Taylor" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
> > Sent: Tuesday, March 20, 2001 5:57 PM
> > Subject: RE: [PHP] Editing Variables from another script.
> >
> >
> > >
> > >
> > > include "database.inc"
> > > .
> > > .
> > > .
> > > .
> > > $dbhost='localhost';
> > >
> > >
> > >
> > > -Stewart
> > >
> > > -----Original Message-----
> > > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> > > Sent: 20 March 2001 09:26
> > > To: Jason Stechschulte
> > > Cc: 'PHP General List. (E-mail)'
> > > Subject: Re: [PHP] Editing Variables from another script.
> > >
> > >
> > > Okay, basically,
> > >
> > > I'm trying to create a script such that it will change the variables
> > inside
> > > of my .inc page.
> > >
> > > Something like
> > >
> > > lets say I have this file called "database.inc"
> > > Inside it I have :
> > >
> > > $dbhost = 'blah'
> > > $dbuser= 'blah'
> > > $dbpass= 'blah'
> > >
> > > I would like to make a script such that I can modify the $variables
into
> > > something else like, $dbhost into localhost.
> > >
> > > How can it be done?
> > > ----- Original Message -----
> > > From: "Jason Stechschulte" <[EMAIL PROTECTED]>
> > > To: <[EMAIL PROTECTED]>
> > > Cc: "'PHP General List. (E-mail)'" <[EMAIL PROTECTED]>
> > > Sent: Monday, March 19, 2001 11:03 PM
> > > Subject: Re: [PHP] Editing Variables from another script.
> > >
> > >
> > > > On Sun, Mar 18, 2001 at 01:06:34PM +0800, [EMAIL PROTECTED]
> wrote:
> > > >
> > > > > I'm trying to create a form whereby I can edit the variables with
> just
> > > the form.
> > > > >
> > > > > It will be something like a form for me to change the database
> > > details(username,server,password) in a .inc I'm using.
> > > > >
> > > > > Is there anyway for me to pass information into another file's
> > variable
> > > and have it saved in there?
> > > > >
> > > > > If anyone have seen Newspro (CGI) before, when you edit some parts
> in
> > a
> > > form, the information will be saved. How can it be done in PHP?
> > > >
> > > > There is probably a hundred or more ways this can be done.  For me
to
> be
> > > > able to give you specifics, you will have to be more specific with
> what
> > > > you are doing and what you have tried.
> > > >
> > > > --
> > > > Jason Stechschulte
> > > > [EMAIL PROTECTED]
> > > > --
> > > > Well, I think Perl should run faster than C.  :-)
> > > >              -- Larry Wall in <[EMAIL PROTECTED]>
> > > >
> > > > --
> > > > PHP General Mailing List (http://www.php.net/)
> > > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > > To contact the list administrators, e-mail:
> [EMAIL PROTECTED]
> > > >
> > >
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > To contact the list administrators, e-mail:
[EMAIL PROTECTED]
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > To contact the list administrators, e-mail:
[EMAIL PROTECTED]
> > >
> > >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail: [EMAIL PROTECTED]
> >
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail: [EMAIL PROTECTED]
> >
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>
>




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to