adamh91 Posted March 1, 2007 Share Posted March 1, 2007 Hey, I was wondering if its possible to edit the variables in another file. e.g. config.php $db_user = "admin"; $db_pass = 'password'; $db_host = 'localhost'; $db_name = 'mail'; somename.php <? include 'config.php'; //Some code to edit the variable stored in config.php ?> Sorry for the bad explanation Is there a way to do this? =s thanks Quote Link to comment Share on other sites More sharing options...
trq Posted March 1, 2007 Share Posted March 1, 2007 Sorry for the bad explanation Then please fix it. Quote Link to comment Share on other sites More sharing options...
adamh91 Posted March 1, 2007 Author Share Posted March 1, 2007 Sorry, I want to edit variables in config.php, would i write a new config.php? Quote Link to comment Share on other sites More sharing options...
adamh91 Posted March 2, 2007 Author Share Posted March 2, 2007 Sorry for the 'bump'. but i need help =[ Quote Link to comment Share on other sites More sharing options...
redarrow Posted March 2, 2007 Share Posted March 2, 2007 What do you wont to do ? looking at your code you want to move thed atabase connection to a single page correct ? Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted March 2, 2007 Share Posted March 2, 2007 If I'm understanding you correctly, Yes you can do that. When you include a file, that file then becomes part of the file it is being included in. So any variables/functions that is in the included file these can be used in the file main file too, variables can also be modified too. Think of include/require as copy 'n' paste. As that is what PHP basically does. Includes are very handy when including frequent bits of code, for example when connecting to a database. Every time you need to connect to a database just simply include the file, rather than having to retype the same bit of code each time. Quote Link to comment Share on other sites More sharing options...
bwochinski Posted March 2, 2007 Share Posted March 2, 2007 Or are you wanting to permanently modify the variables in config.php? As in storing the Database config. Quote Link to comment Share on other sites More sharing options...
adamh91 Posted March 2, 2007 Author Share Posted March 2, 2007 Or are you wanting to permanently modify the variables in config.php? As in storing the Database config. Yeah i was refering to that sorry. thanks for everyones help but ive decided to store it differently ^^ Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.