As you can probably tell, config.php is where we hold the configuration information for our websites. I will sketch out basicly how i’m doing this.

First we load up the database interface module.

require ‘DB.php’;

the variables below are so I dont have to type our those strings a million times in my code.

$prep = $_SERVER[’PHP_SELF’];
$query = $_SERVER[’QUERY_STRING’];
$http_host = $_SERVER[’SERVER_NAME’];

I put this body tag in here incase I wanted to use some javascript later on.

$body_tag = ‘‘;

Ok, now for the database stuff. First I set up my variables needed to connect.

$db_host = ‘localhost’;
$db_login = ‘Multi’;
$db_pass = ‘i took out the pass you newb’;
$db_name = ‘multi’;

// no editing should be needed beyond this point

The next step is to actually make the connection to the database.

$db = DB::connect(”mysql://$db_login:$db_pass@$db_host/$db_name”);
if (DB::isError($db)){ die (”Can’t connect: ” . $db->getMessage()); }
// error handling
$db->setErrorHandling(PEAR_ERROR_DIE);

Here we contact the db, and retrieve information specific to this website. Later we will reference these as global variables. I’ve thought about a possible injection problem with my query below, but I cant see how it would be a problem, $_SERVER[’http_host’] will always be a domain. If you dont call the right domain, the query would never be executed anyway.

$t = $db->query(”SELECT category, stylesheet, page_title, comments, preamble, meta_kw, meta_desc from virtual_1 where site_id = ‘$http_host’”);
while ($row = $t->fetchRow()){
$category = $row[0]; // this is what category our site belongs to
$stylesheet = $row[1]; // this is the stylesheet we will be using
$change_title = $row[2]; // title for site
$comments = $row[3]; // site’s main page content
$preamble = $row[4]; // preamble is where I will put a quick site description.
$meta_description = $row[5]; // meta description tag content.
$meta_keywords = $row[6]; // meta keywords tag content.

}