• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

PHP: Access variables from another php file?

Right now on my website, when I want to connect to a DB, I have the login variables stored on every single PHP file on my site.

Is there any way to store the DB login information in a separate file and then anytime the the PHP file needs to connect to the DB, it accesses the external file for the information?
 
Originally posted by: Dynamite
Right now on my website, when I want to connect to a DB, I have the login variables stored on every single PHP file on my site.

Is there any way to store the DB login information in a separate file and then anytime the the PHP file needs to connect to the DB, it accesses the external file for the information?

yes.

use include("filename").

include will dump the contents of a file right into the script that calls it. look up the doc on php.net and report back if you run into difficulty. 🙂
 
Back
Top