I have been developing a system in PHP that uses MySQL. To that end, I have used a config file to hold high level fixed variables (database name, user id, password, etc) and I using "require_on ce" to get it into my code with no problems.
The problem arises from my desire to integrate third party software, such as Wordpress, External Calendar, etc, into my site and have one central location for database configuration.
I can successfully use "require_on ce" in WP's or X2's code but when I refer to variables set in my include file, they seem to be null, which is puzzling. This is a snippet from my include file:
[php]
<?
$gs_database = "linwoods_onlin edems";
$gs_username = "linwoods_admin ";
$gs_password = "plush32331 ";
?>
[/php]
That's not all in the file but is the relevant part. I set about a dozen variables and I can successfully refer to them in my code. Here is an example from X2:
[php]
<?php
require_once ('http://'.$_SERVER['HTTP_HOST'].'/lcs_config.php' );
// ExtCalendar configuration file
// DB configuration
$CONFIG['dbsystem'] = "mysql"; // Your database system
$CONFIG['dbserver'] = "localhost" ; // Your database server
$CONFIG['dbuser'] = $gs_username; // Your db username
$CONFIG['dbpass'] = $gs_password; // Your db password
$CONFIG['dbname'] = $gs_database; // Your database name
echo "|".$gs_usernam e."|";
?>
[/php]
It finds the file alright because if I change the file name, it breaks. The problem is that the variable I'm echoing is NULL. This is happening in three different external applications I'm trying to integrate so I'm stumped as to why this is happening. I've been on google for the last 2 hours with no success.
Any ideas?
Thanks!
Paul
The problem arises from my desire to integrate third party software, such as Wordpress, External Calendar, etc, into my site and have one central location for database configuration.
I can successfully use "require_on ce" in WP's or X2's code but when I refer to variables set in my include file, they seem to be null, which is puzzling. This is a snippet from my include file:
[php]
<?
$gs_database = "linwoods_onlin edems";
$gs_username = "linwoods_admin ";
$gs_password = "plush32331 ";
?>
[/php]
That's not all in the file but is the relevant part. I set about a dozen variables and I can successfully refer to them in my code. Here is an example from X2:
[php]
<?php
require_once ('http://'.$_SERVER['HTTP_HOST'].'/lcs_config.php' );
// ExtCalendar configuration file
// DB configuration
$CONFIG['dbsystem'] = "mysql"; // Your database system
$CONFIG['dbserver'] = "localhost" ; // Your database server
$CONFIG['dbuser'] = $gs_username; // Your db username
$CONFIG['dbpass'] = $gs_password; // Your db password
$CONFIG['dbname'] = $gs_database; // Your database name
echo "|".$gs_usernam e."|";
?>
[/php]
It finds the file alright because if I change the file name, it breaks. The problem is that the variable I'm echoing is NULL. This is happening in three different external applications I'm trying to integrate so I'm stumped as to why this is happening. I've been on google for the last 2 hours with no success.
Any ideas?
Thanks!
Paul
Comment