how to load DB login info from external file?
Posted: Mon Dec 13, 2010 9:14 pm
At the top of several pages, I have the following code to connect to a DB:
I'd like to externalize it using require_once or something like that, so that I only have to maintain one file (it will have other configuration settings as well). When I tried require_once, it just displayed the single line from the file and then died.
What is the right/best approach?
file_get_contents()
require_once()
include_once()
Something else?
Code: Select all
$mysqli = new mysqli("localhost", "db_user", "db_password", "db_name");What is the right/best approach?
file_get_contents()
require_once()
include_once()
Something else?