0

HI CONSTANTS in my customer site are affecting my admin site. i don't know why. also when i browse for admin site and if index.php file is not available home.php file loads. i find this very weird... can anyone please help me? following is some of the errors it generates. this file C:\xampp\htdocs\currency_rates\lib\config.php is in my customer site not in admin but the file im calling in my admin home page is C:\xampp\htdocs\currency_rates\admin\lib\config.php it seems both are being called but i can't understand how????
first i thought it might be a session conflict then i used different browsers but results are the same.

Notice: A session had already been started - ignoring session_start() in C:\xampp\htdocs\currency_rates\lib\config.php on line 2

Notice: Constant SERVER already defined in C:\xampp\htdocs\currency_rates\lib\config.php on line 8

Notice: Constant UNAME already defined in C:\xampp\htdocs\currency_rates\lib\config.php on line 9

Notice: Constant PASSWORD already defined in C:\xampp\htdocs\currency_rates\lib\config.php on line 10

Notice: Constant DB_NAME already defined in C:\xampp\htdocs\currency_rates\lib\config.php on line 11

Notice: Constant SERVER_ROOT already defined in C:\xampp\htdocs\currency_rates\lib\config.php on line 14

Notice: Constant WEBSITE already defined in C:\xampp\htdocs\currency_rates\lib\config.php on line 17

Notice: Constant DS already defined in C:\xampp\htdocs\currency_rates\lib\config.php on line 20

Notice: Constant APP_ROOT already defined in C:\xampp\htdocs\currency_rates\lib\config.php on line 23

BY the WAY paths are correct in my code.

Notice: Constant MODEL_PATH already defined in C:\xampp\htdocs\currency_rates\lib\config.php on line 29

Edited by Virangya: n/a

3
Contributors
8
Replies
9
Views
5 Years
Discussion Span
Last Post by diafol
0

Hey i found that when ever , where ever my database class in included it generates these errors. this is my database class.

<?php

error_reporting(E_ALL);
ini_set("display_errors", 1);
//require_once("config.php");

class Database{

	private $connection;

	function __construct()
	{
		$this->open_connection();
	}

	public function open_connection()
	{
	
		$this->connection= mysql_connect(SERVER,UNAME,PASSWORD);
	
		if(!$this->connection)
		{
			return false;
		}
		if(!mysql_select_db(DB_NAME,$this->connection))
		{
			return false;
		}
		return true;
	}

	public function close_connection()
	{
		mysql_close($this->connection);
	}

}

$database = new Database();

//just to test
/*if($database->open_connection())
	{
		echo("connection working! <br />");
	}
else
	{
		echo("error connecting <br />");
	}*/
?>
0

Although consistent use of require_once should avoid this problem, here's another way to check your constants.

actually these same constants are defined in a file in another directory. but i am not calling that file here (require_once()) so if i'm not calling it anywhere here how can it say "already defined"?????????? :(

0

show your code
we can only guess at what you're facing
include any dependencies (or include files)

0

this is the only php code in my home.php file.

<?
require_once('../lib/config.php');
require_once(LIB.'database.php');
?>

config.php file defines the constants

<?php
session_start();

error_reporting(E_ALL);
ini_set("display_errors", 1);

//databse related constants
define('SERVER','localhost');
define('UNAME','root');
define('PASSWORD','');
define('DB_NAME','dbcurrencyrates');

//server root
define('SERVER_ROOT',$_SERVER["DOCUMENT_ROOT"]);

// address of website.
define('WEBSITE', 'http://localhost/');

//directory separator
define('DS','/');

//application directory
define('APP_ROOT','currency_rates');

//secondary directory
//define('SEC','APP');

//mvc directories
define('MODEL_PATH',SERVER_ROOT.DS.APP_ROOT.DS.'admin'.DS.'models'.DS);
define('VIEW_PATH',SERVER_ROOT.DS.APP_ROOT.DS.'admin'.DS.'views'.DS);
define('CONTROLLER_PATH',SERVER_ROOT.DS.APP_ROOT.DS.'admin'.DS.'controllers'.DS);

//lib directory
define('LIB',SERVER_ROOT.DS.APP_ROOT.DS.'lib'.DS);

//url to the controller web address
define('CONTROLLER_URL',WEBSITE.APP_ROOT.DS.'controllers'.DS);

include('controller.php');
include('model.php');
include('view.php');
?>

and as long as i don't include that database.php (code posted in a previous post) file it works fine. but when i do, it generates those errors. and the paths in generated message says that errors are in a file i have never included anywhere. that file is in my customer site. and it contains a code 99% similar to config.php but in a different directory. and so it contains same constants. but i never included it in anywhere :-o so how could this happen?

0
require_once('../lib/config.php');
echo LIB.'database.php';
require_once(LIB.'database.php');

how about that, just to see that LIB actually points to the directory you expect.

how about temporarily hard coding the LIB constant in the second require_once call?

0

Hey, I did i as you said. now it works.... thanx..!!! But do you have any idea why it happens that way..?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.