You cannot make changes to a file without writing the entire contents of the file to disk. On the other hand, you do not need to manually re-create the entire contents. Simple read the file into a variable and use regular expressions to replace the old lines with new ones and then write the file to disk. For what its worth, I cannot think of a justification for keeping any settings other than database settings in a file. I would recommend keeping all settings, other than database access settings, in a database. This makes accessing and updating the settings much easier. The only reason database settings must be in a file is because you obviously cannot access the database without them (unless you use default settings in the php.ini file).
Fred Jeff Lewis <[EMAIL PROTECTED]> wrote in message 002801c17ad9$7ec8b820$0100a8c0@cr983033a">news:002801c17ad9$7ec8b820$0100a8c0@cr983033a... > I have a file that contains settings and there are a lot of comments in > there and a lot of variables. An excerpt of the file looks like below. My > question is, is it possible to change only certain variables? For example, > I want to set just the db variables, is it possible for me to input the new > values in a form and replace only those in the file without having to > rewrite the entire file? > > $mailtype = 0; # 0 - sendmail, 1 - SMTP > > ########## Database Info ########## > $db_name = "name"; > $db_user = "user"; > $db_passwd = "pass"; > $db_server = "localhost"; > > ########## Directories/Files ########## > # Note: directories other than $imagesdir do not have to be changed unless > you move things > > $boarddir = "."; # The absolute path to the folder (usually can be left > as '.') > $sourcedir = "./Sources"; # Directory with source files > > -- 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]