Fatal error: Cannot redeclare function

I’m trying to call images all the images from a folder to display on screen in an iframe. I added a back end function for the admin to delete the images from the folder if they choose. After setting this up I went back to see if the images were being deleted and I was met with this error:

Fatal error: Cannot redeclare addPost() (previously declared in /home/s519970/public_html/includes/functions.php:99) in /home/s519970/public_html/includes/functions.php on line 117.

I’ve looked for instances where I might have called my functions.php file again but there doesn’t seem to be any. What’s confusing me is that the addPost() function I’ve been using has never been in my includes/functions.php file but in my admin/includes/functions.php file.

The code calling the files is:

[php]$handle = opendir(dirname(realpath(FILE)).’/admin/img/albumOne/’);
while($file = readdir($handle)){
if($file !== ‘.’ && $file !== ‘…’){
echo ‘’;
}
}[/php]

I’m not really sure what else to post up but if theres any other code of info I can provide let me know.

Any help is greatly appreciated!

After reading this post back in a preview it doesn’t sound like the two are related as addPost() is unrelated to the gallery. I must be missing something in my code, perhaps some advice on what to look for would be better to ask for, rather than a solution. Thanks

Hi,

Well first off, I doubt very strongly opening images is going to cause this error. Like you said in the last line. I have to agree with that.
If you do look in the file which the error tells you the addPost() is in, does it indeed have a ‘function addPost( bla )’ declaration on line 99? And then one on line 117? If so, try commenting out one. See which one ( if they’re not identical ) you need and leave the other one out.

It’s all I can think off at the moment.
Hope it helps ( a little )
O.

Oh, wait, if you know where the addPost() function is declared you could replace it by a stacktrace ( comment one out, write something that displays a stacktrace and call that addPost().
When it gets called you can see where it gets called and how. ( if you follow the stacktrace all the way back you get to the first PHP-file you loaded )

Success! :slight_smile:

There has never been an addPost() function in the includes/function.php file. It only ever occurs in my admin area, which is: admin/includes/functions.php.

I’ve checked in this file for multiple addPost()'s but there is only one. That occurs on line 99, which makes it stranger that the error says the function first appeared on line 99 and now has been redeclared on line 117, which it hasn’t.

Im not familiar with stacktraces, can you give me an example to try?

Sponsor our Newsletter | Privacy Policy | Terms of Service