Not wanting this question to be too long, I will skip to an example:
If I have 2 files: paper.php and rock.php, and they contain the following:
paper.php:
include('rock.php');
$link = mysql_connect(DB_HOST, DB_USER, DB_PASS) or die("Couldn't make connection.");
$db = mysql_select_db(DB_NAME, $link) or die("Couldn't select database");
and rock.php:
define ("DB_HOST", "localhost");
define ("DB_USER", "foo");
define ("DB_PASS","bar");
define ("DB_NAME","fooDBar");
Eventually, will the user viewing my paper.php file be connected to the DB or not?
Yes, you define all the appropriate variables in
rock.phpand are includingrock.php, then they will be defined for the whole program execution, including where you do amysql_connect().