imarockstar Posted November 24, 2008 Share Posted November 24, 2008 I am trying to write to a setting file which holds database connectivity info .. I am haing a hard time figuring out the best way to do this ... the following is what I need to write to : <?php define ('DB_USER', 'dbuser'); define ('DB_PASSWORD', 'password'); define ('DB_HOST', 'localhost'); define ('DB_NAME', 'dbname'); $dbc = mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) OR die('Could not connect to MySQL: ' . mysql_error()); mysql_select_db (DB_NAME) OR die('Could not select the database: ' . mysql_error()); ?> The user is going to fill out a form then it will post and write to this php file called settings.php ... could some one tell me the best way to do this or point me in the direction of a good tutorial ? thanks b Quote Link to comment https://forums.phpfreaks.com/topic/134106-writing-to-file-help/ Share on other sites More sharing options...
jkewlo Posted November 24, 2008 Share Posted November 24, 2008 what are you trying to do? write it to a file or store it in the database Quote Link to comment https://forums.phpfreaks.com/topic/134106-writing-to-file-help/#findComment-698075 Share on other sites More sharing options...
imarockstar Posted November 24, 2008 Author Share Posted November 24, 2008 The script I wrote pulls data from a database and I am trying to make it easier for the user to install. So I want the install script to write to a "settings' file so the user does not have to edit the file directly. The install file will ask the user for the database info, the user will input it into a form then the script will write the users database info to the settings file. Quote Link to comment https://forums.phpfreaks.com/topic/134106-writing-to-file-help/#findComment-698090 Share on other sites More sharing options...
premiso Posted November 24, 2008 Share Posted November 24, 2008 Do you have part of the script coded already? If so show us what you have. The basic gist would be to use fopen and fwrite to write the contents to a file and save it. You should find plenty of examples at those functions manual on php.net. Quote Link to comment https://forums.phpfreaks.com/topic/134106-writing-to-file-help/#findComment-698093 Share on other sites More sharing options...
imarockstar Posted November 24, 2008 Author Share Posted November 24, 2008 I did see those examples, but it ... wait a minute ... let me check something then I will continue .. i think it just clicked in my little brain ... lol b Quote Link to comment https://forums.phpfreaks.com/topic/134106-writing-to-file-help/#findComment-698130 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.