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:[EMAIL PROTECTED]/$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

Reply via email to