I have a settings file in the site I am developing which contains global site settings using this structure:
define("DB_SERVER", "localhost");
What I'd like to do instead, is create a table in the database which contains the globals and call them like:
---------------------
// Connect to the database
$conn = mysql_connect("localhost", "user", "password") or die(mysql_error());
// Grab global variables from the Site Preferences table
$query = "SELECT field, value FROM prefs ORDER BY id ASC";
$getGlobals = mysql_query($query, $conn);
while($global = mysql_fetch_array($getGlobals)){
   $field = stripslashes($global['field']);
   $value = stripslashes($global['value']);
   define($field, $value);
}
// Close the connection
mysql_close($conn);
---------------------
I can't seem to get this working though...When I call any of the defined globals they aren't recognized as defined. Anyone have suggestions on how I can get this to work?
Tags: