connect.php in a folder called
includes. The includes folder is in the root of the web application.
Then in any file I need to execute an SQL query to the database:
include_once $_SERVER['DOCUMENT_ROOT'] . "/includes/connect.php";
Extra points to address
For using the
$mysqli variable for executing queries and such (using OOP) in PHP, read the following articles;
For executing queries: http://php.net/manual/en/mysqli.query.php Note: I prefer to use Object Oriented style instead of the Procedural style.
For more information, consult: http://php.net/manual/en/class.mysqli.php