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 Link to comment https://forums.phpfreaks.com/topic/40711-solved-write-external-variables/ 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. Link to comment https://forums.phpfreaks.com/topic/40711-solved-write-external-variables/#findComment-197035 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? Link to comment https://forums.phpfreaks.com/topic/40711-solved-write-external-variables/#findComment-197157 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 =[ Link to comment https://forums.phpfreaks.com/topic/40711-solved-write-external-variables/#findComment-197977 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 ? Link to comment https://forums.phpfreaks.com/topic/40711-solved-write-external-variables/#findComment-197988 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. Link to comment https://forums.phpfreaks.com/topic/40711-solved-write-external-variables/#findComment-198017 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. Link to comment https://forums.phpfreaks.com/topic/40711-solved-write-external-variables/#findComment-198022 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 ^^ Link to comment https://forums.phpfreaks.com/topic/40711-solved-write-external-variables/#findComment-198029 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.