What am i doing wrong when i get this error? I just added my global.inc file to news.php (so i dont have to have two global file, when i can actually use one and the same) but then i get this:
Fatal error: Cannot redeclare db_connect() (previously declared in C:\www\Apache\htdocs\inc\functions.lib.php:24) in C:\www\Apache\htdocs\inc\functions.lib.php on line 21
redeclare?
Moderator: General Moderators
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
It looks like you declare a function called db_connect() twice in the functions.lib.php file.
So you have two lines that look something like this,
Mac
So you have two lines that look something like this,
Code: Select all
function db_connect($some_vars) {this also happens if a function is included (include/require) twice.
if your script includes 'functions.lib.php' and global.inc does the same......
you may prevent this by something like this
EDIT: ok, include_once is better - didn't know this exits 
if your script includes 'functions.lib.php' and global.inc does the same......
you may prevent this by something like this
Code: Select all
if(!declared('functions.lib.php-included')) { define('functions.lib.php-included');
...<functions.lib.php code > ...
}
Last edited by volka on Thu Jun 06, 2002 2:02 am, edited 2 times in total.
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
If you are including the same file in a number of different locations and thus accidentally reincluding the file try using include_once so that if the code from the file has already been included it won't be again.
Mac
Mac