My problem is now that I have a lot of files and I am having big problems with getting certain variables to certain pages.
ex. I have a page called config.php:
<?php
// the location of your mysql server
$mySQL_Host = "localhost";
// your mySQL username
$mySQL_User = "root";
// your password for the above account
$mySQL_Pass = "xxxxx";
// your mysql database name
$mySQL_Database = "kurtzdownloaddb";
// the prefix you'd like to use for the tables
$mySQL_DB_Prefix = "kurtz";
//**************************//
//DO NO EDIT BELOW THIS LINE//
//**************************//
$db = array( $mySQL_Host, $mySQL_User, $mySQL_Pass, $mySQL_Database, $mySQL_DB_Prefix );
?>
and my functions page:
<?php
function parseTemplate( $fTemplateFile, $config )
{
global $string;
$fileContents = file_get_contents( $fTemplateFile );
foreach( $string as $tag => $value )
{
$tag = "{" . $tag . "}";
$fileContents = str_replace( $tag, $value, $fileContents );
}
return $fileContents;
}
?>
and then mysql.php:
<?php
class mysql {
private $conn;
private $result;
private $querySingle;
private $resultSingle;
private $queryAll;
private $resultAll;
public function __construct( $fSqlArray )
{
$this->conn = mysql_connect( $fSqlArray[0], $fSqlArray[1], $fSqlArray[2] );
mysql_select_db( $fSqlArray[3] );
}
public function query( $fQuery , $fResultType = "0" )
{
switch( $fResultType )
{
case 0: $this->result = $this->mysql_fetch_single( $fQuery ); break;
case 1: $this->result = $this->mysql_fetch_all( $fQuery ); break;
}
return $this->result;
}
private function mysql_fetch_single( $fQuerySingle )
{
$this->querySingle = mysql_query( $fQuerySingle, $this->conn );
$this->resultSingle = mysql_fetch_array( $this->querySingle );
return $this->resultSingle;
}
private function mysql_fetch_all( $fQueryAll )
{
$this->queryAll = mysql_query( $fQueryAll, $this->conn );
$this->resultAll = array( );
while( $fRow = mysql_fetch_array( $this->queryAll ) )
{
$this->resultAll[] = $fRow;
}
return $this->resultAll;
}
}
$mysql = new mysql;
$config = $mysql->query("SELECT * FROM $db[4]_settings", 0);
?>
and lastly english.php
<?php
$string['TITLE'] = $config[0];
$string['VERSION'] = "version 0.1.1 BETA";
$string['STYLESHEET'] = "../src/themes/$config[3]/style.css";
$string['COPYRIGHT'] = "Copyright © 2005 by Shawn Kurtz";
?>
The problem is that I need a new way of including these things. For example, in order for my template parser to work, it requires the array from "english.php" and in order for "english.php" to work it needs the $config array that was outputed from "mysql.php"
Is there a more simplistic way of sorting this out?