» Home
Tuesday, September 26, 2017 - 03:34:07

PHP: How to store system configurations on a database and use them as constants?

I'd like to have constants in PHP which are retrieved from a database. Essentially, I'd like to create a page that can update this database table so the next time I load the site, it will use these newly updated constants which are again retrieved from the database.

I'm looking for things that can be changed directly by the admin without needing to go into the source code and manually changing the hardcoded constants file.

Asked by demouser 5 years ago In Programming, answers (1), visited (1218)

database php constants

Posted on : Sunday, February 3, 2013, 07:40:50 In Programming

niki33

Make a settings file and put this in it (settings.php)
<?php
$cfg_server="serveraddress";
$cfg_database="dbname";
$cfg_username="username";
$cfg_password="dbpassword";
?>


Now just put this in any file that needs to access the database

include ("settings.php");
$link = mysql_connect("$cfg_server","$cfg_userna…
or die("error ");


mysql_select_db ("$cfg_database", $link)
or die("error ");
Answered: Sunday, February 3, 2013, 07:55:31, 5 years ago User Rating: 2  Votes: +3 -1
Last Questions

What is enigma?

I am confused about word enigma. What is that? Posted on : Thursday, August 31, 2017, 22:45:55

What's the worst Star Wars film?

Episode 1 Episode 2 Episode 3 Episode 4 Episode 5 Episode 6 Episode 7 Posted on : Tuesday, January 17, 2017, 13:07:53

ce filme va plac?

voua ce filme va plac sau urmariti in general? Posted on : Sunday, November 27, 2016, 14:29:46

What is the best programming language to start with?

Hello! I am wanting to learn programming, but I dont know which language I should start off... Posted on : Saturday, November 12, 2016, 02:35:09

How old James bond ?

Hi , How old James bond ? Any body know ? Posted on : Wednesday, March 30, 2016, 21:37:39

What is social bookmarking?

Can somebody explain me what mean social bookmarking? Is good for traffic to website or what?... Posted on : Sunday, August 23, 2015, 10:26:36

What is the best way to play guitar?

Want to know who knows how to play guitar Posted on : Monday, July 13, 2015, 21:03:39

what is dreamweaver

i want to know about the software of adobe named dremaweaver? Posted on : Tuesday, August 12, 2014, 17:03:41