I have three PHP files like following :
config.php
<?php
session_start();
$database_server = "localhost";
$database_name="dbname";
$database_username="root";
$database_password="";
$_SESSION["server"] = $database_server;
$_SESSION["dbname"] = $database_name;
$_SESSION["dbuser"] = $database_username;
$_SESSION["dbpassword"] = $database_password;
?>
db.php
<?php
include("config.php");
session_start();
//config file for database
$con = mysql_connect($_SESSION["server"],$_SESSION["dbuser"],$_SESSION["dbpassword"]) or die(mysql_error());
if ($con)
{
$dbhandler = mysql_select_db($_SESSION["dbname"] , $con) or die(mysql_error());
}
else
{
echo "not possible to connect to database";
}
?>
header.php
<?php
include ("../config/db.php");
?>
<div class="topbar">
<div class="fill">
<div class="container">
<h3><a href="#">title</a></h3>
<ul>
<li><a href="#">General Config</a></li>
<li class="active"><a href="#">Add title</a></li>
<li><a href="#">title</a></li>
<li><a target="_blank" href="http://www.site.com/">website</a></li>
</ul>
</div>
</div>
</div>
I am developing using xampp and everytime I try to run the header.php I'll get these errors :
Deprecated: Assigning the return value of new by reference is deprecated in C:\xampp\php\PEAR\Config.php on line 80
Deprecated: Assigning the return value of new by reference is deprecated in C:\xampp\php\PEAR\Config.php on line 166
Notice: Undefined index: server in C:\xampp\htdocs\ossila\config\db.php on line 5
Notice: Undefined index: dbuser in C:\xampp\htdocs\ossila\config\db.php on line 5
Notice: Undefined index: dbpassword in C:\xampp\htdocs\ossila\config\db.php on line 5
Notice: Undefined index: dbname in C:\xampp\htdocs\ossila\config\db.php on line 8
To be honest I don't have any idea where is these problems comes from? I'm using xampp 1.7.7 (latest version) is it because of some misconfiguration in xampp? or should I use some other way to config the session?
session_start()out of your db.php file? (Blind guessing)$_SESSION["dbpassword"] = $database_password;Deprecatedmessages come from PEAR and are caused by code that is there for PHP4. If you want to fix the problems, you could go an look inC:\xampp\php\PEAR\Config.phpwhere you will find on lines 80 and 166 that there are lines that look like this:$var = &new ClassName;. All you need to do to fix this is remove the&. It won't break anything on your server, it's just there for PHP4 backwards compatibility. Or you could safely ignore it, and turn error reporting off in production (as you should anyway).