Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/134106-writing-to-file-help/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/134106-writing-to-file-help/#findComment-698090
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/134106-writing-to-file-help/#findComment-698093
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.