Jump to content

Archived

This topic is now archived and is closed to further replies.

shimano55

Changing a Value in a config.php

Recommended Posts

Hey everyone. I need to know how to use php to change the value of a variable in my configuration file and resave the file with the variable having its new value. For instance, I want to change:

[code] $var1 = 1; [/code]
to
[code] $var1 = 0; [/code]

and then save the file with the new value for $var1.

Thanks,
shimano55

Share this post


Link to post
Share on other sites
You will want to look at [a href=\"http://uk.php.net/manual/en/function.fopen.php\" target=\"_blank\"]fopen[/a] and [a href=\"http://uk.php.net/manual/en/function.fwrite.php\" target=\"_blank\"]fwrite[/a] for what you want to do.

Share this post


Link to post
Share on other sites
I don't know if I just missed something, but what formate is the configuration file? If it is .php then just use wordpad & just save it.

Share this post


Link to post
Share on other sites
[!--quoteo(post=364847:date=Apr 14 2006, 12:27 PM:name=lansing)--][div class=\'quotetop\']QUOTE(lansing @ Apr 14 2006, 12:27 PM) [snapback]364847[/snapback][/div][div class=\'quotemain\'][!--quotec--]
I don't know if I just missed something, but what formate is the configuration file? If it is .php then just use wordpad & just save it.
[/quote]


"[b]I need to know how to use php[/b] to change the value of a variable in my configuration file"

Share this post


Link to post
Share on other sites
wildteen88 has the right answer

the php configuration file is a .ini file, you'll have to write some code to safely change the variables without messing the file up... maybe such code already exists, search google for it.

some hosts don't give you access to the ini file though.

There are also some ini values you can temporarily change (more like ignore) while the script is running. I know that's not what you wan't to do.. but just letting you know it's possible.


Edit:

Opps... I think I missunderstood what you meant by "configuration file"... are you talking about the main php ini file... or a file you've made?
Still tho.. wildteen88 has the right answer

Share this post


Link to post
Share on other sites
You should look at the function [a href=\"http://www.php.net/parse_ini_file\" target=\"_blank\"]parse_ini_file[/a]() and see if that helps you.

Ken

Share this post


Link to post
Share on other sites
Umm, I dont think [b]shimano55[/b] wants to edit his php.ini file but a configuration file, ie config.php, for his script to edit a the value of $var1 to 0. shimano55 [b]doesn't[/b] want to edit the php.ini.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.