error=could not connect to localhost
Posted: Thu Jun 22, 2006 9:50 pm
I keep getting error=could not connect to localhost
with a page that has
with Page2.php being:
and the conf.inc.php page being:
I use the same conf.inc.php on other pages and it works fine. What is wrong!
with a page that has
Code: Select all
<?php
require("page2.php");
?>Code: Select all
b_start();
require_once("conf.inc.php");
session_start();
// Check to see if user is logged in and what there username is
if(isset($_SESSION['username']) && isset($_SESSION['loggedin'])){
// If user is logged in SESSION session variables
if($_SESSION['loggedin']==1){
$username = $_SESSION['username'];
if(isset($_SESSION['pass'])){
$pass = $_SESSION['pass'];
}
$loggedin = $_SESSION['loggedin'];
if(isset($_SESSION['time'])){
$time = $_SESSION['time'];
}
}
} else {
// Set user is not logged in if session is not detected
$_SESSION['loggedin'] = 0;
$loggedin = $_SESSION['loggedin'];
die;
}
// now only process if user is logged in
if($loggedin == 1){
// Get user Information
$info = mysql_unbuffered_query("SELECT * FROM `users` WHERE user = '{$username}' ");
$info = mysql_fetch_array($info);
// If Account is locked out redirect
if(isset($userinfo['Locked'])){
if($userinfo['Locked']==1){
header("Location: ../../Locked.php");
}
}
// Get other required user infomation
$last_login = $info ['Last_Login'];
$activate = $info ['Activated'];
$current_time = date("Y");
//end of only process if user is logged in code
}
// FLUSH
ob_flush();
?>Code: Select all
<?php
ob_start();
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Data passata
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
// sempre modificato
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
error_reporting(E_ALL);
$host = 'localhost';
$dbuser = 'user';
$dbpass = 'pass';
$dbname = 'db';
$table = '';
$db = @mysql_connect($host,$dbuser,$dbpass) or die("Error! Could not connect to host." . mysql_error() . "");
$db = mysql_select_db($dbname);
if(!$db)
{
print "Error! Could not connect to database.";
exit;
}
ob_flush();
?>