PHPLib Include - Help!
| From: | Matt Stone | Date: | Mon, 01 Jan 2001 03:07:16 +0000 |
| Subject: | PHPLib Include - Help! | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-32379@lists.php.net to get a copy of this message | ||
Hi,
I developed at script on my server in which PHPLib was not automatically
added to the head of my PHP files. This way I could manually include them
and then check to see if the had been included as not to redeclare the class
like so:
if (!isset($LIBVAR) or !is_array($LIBVAR)){
$_PHPLIB["libdir"] = "c:/inetpub/phplib/php/";
include($_PHPLIB["libdir"] . "db_mysql.inc");
class TheDB_Sql extends DB_Sql {
var $Host = "*****";
var $Database = "*****";
var $User = "*****";
var $Password = "*****";
}
$Db=new TheDB_Sql;
}
However I just installed the script on a different server where PHPLib is
automatically added to the head of PHP files. So now I have something like
this:
if (!isset($LIBVAR) or !is_array($LIBVAR)){
//$_PHPLIB["libdir"] = "c:/inetpub/phplib/php/";
//include($_PHPLIB["libdir"] . "db_mysql.inc");
class TheDB_Sql extends DB_Sql {
var $Host = "*****";
var $Database = "*****";
var $User = "*****";
var $Password = "*****";
}
$Db=new TheDB_Sql;
}
But here we have another problem. Seen as PHPLib is automatiaclly added,
then
if (!isset($LIBVAR) or !is_array($LIBVAR))
will always return false. SO I change it to this:
//if (!isset($LIBVAR) or !is_array($LIBVAR)){
//$_PHPLIB["libdir"] = "c:/inetpub/phplib/php/";
//include($_PHPLIB["libdir"] . "db_mysql.inc");
class TheDB_Sql extends DB_Sql {
var $Host = "*****";
var $Database = "*****";
var $User = "*****";
var $Password = "*****";
}
$Db=new TheDB_Sql;
//}
But this as you can see is defeating the whole purpose and now the $Db=new
TheDB_Sql; is executed multiple times and causing this error:
Fatal error: Cannot redeclare class thedb_sql in
/home/www/htdocs/planetveggie/namebank/libraries/secure.php
Any ideas? Please help. Thanks,
Matt Stone
_______________________________
This email may contain confidential and/or privileged information for the
sole use of the intended recipient. Any review or distribution by others is
strictly prohibited. If you have received this email in error, please
contact the sender and delete all copies. Opinions, conclusions or other
information expressed or contained in this email are not given or endorsed
by the sender unless otherwise affirmed independently by the sender.
_________________________________