2 sites accessing 1 db - problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I have a master database and a customer-facing website and a staff-facing
website - both connecting to the same database. I use Smarty and PEAR::DB
and PHP5.

I have no problem connecting from one site, but the other just generates
'could not open database' on the home page. This is happening on the log-in
page.

I've checked the code and its virtually identical, except for the different
tables being queried. One works, one doesn't.

I use a config file to ease development/deployment:

"Config.php"
<?php
	if($_SERVER['SERVER_NAME']=='myserversite'){
		$incloc="c:\\inetpub\\wwwroot\\egret\\includes\\";
		$smartyloc="c:\\php\\Smarty\\";
		$incloc="c:\\inetpub\\wwwroot\\egret\\includes\\";
		$server_url="http://myserversite/egret/";;
	} else {
		$incloc="c:\\inetpub\\wwwroot\\egret\\includes\\";
		$smartyloc="c:\\php\\";
		$server_url="http://localhost/egret/";;
	}
	if((isset($_COOKIE['access'])&&$_COOKIE['access']=='')||(isset($_POST['acce
ss'])&&$_POST['access']=='')){
		header("Location: ".$server_url."home.php");
	}elseif(isset($_COOKIE['access'])&&$_COOKIE['access']!='') {
		$access = $_COOKIE['access'];
	}
	$dbhost = 'localhost';
	$dbuser = 'root';
	$dbpass = '';
	$dbname = 'egret';
	require_once( 'DB.php' );
	$db =& DB::connect( "mysql://$dbuser:$dbpass@$dbhost/$dbname" );
?>
============================================================================
======================
"home.php"
<?php
	include("includes/config.php");
	require $smartyloc."Smarty.class.php";
	$smarty    = new Smarty;

	$sql = "SELECT account_id, nickname FROM account";
    	$loginResult = $db->query($sql);
	$recCount = $loginResult->numRows();
	$i=0;
	$results=array();
    	while ($loginRow = $loginResult->fetchRow()) {
			$tmp = array(
			'id' => $loginRow[0],
			'hei'=> $loginRow[1]
			);
			$results[$i++] = $tmp;
	}
    	$db->disconnect();
	$smarty->assign('results', $results);
	$smarty->display('home.tpl');
?>
======================================================================
Am I missing something obvious?

Cheers

George in Oxford

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux