How to generate config. I just learned php from a database configuration file such as PHP. after I write a PHP file for creating a database and creating a form, I want to enter the database address, database username, and database password, create a config. how should I write php files stored in it for database operations? The following shows how to generate a database configuration file, such as config. php, for the user input data created in the form.
I just learned PHP and wrote a PHP code for creating a database and creating a form. I want to create a config with the database address, database username, database password, and created database name entered by the user. how should I write php files stored in it for database operations?
The following code retrieves the user input data in the form to create a database:
PHP code
------ Solution --------------------
$ Fp = fopen ('config. php', 'W + ');
$ Config = "configure: \ r \ n ";
$ Config. = '$ DB [\ 'address \'] = '. $ sqladdress. "\ r \ n ";
//... Something like this
Fwrite ($ fp, $ config );
Fclose ($ fp );
Then, when reading the configuration file:
Include 'config. php ';
Mysql_connect ($ DB ['address'],...)
------ Solution --------------------
Just put it in the database...
Put the file in the same way. you can simply put the json or csv format into the file. next time, you can easily parse the file.