I tried changing a require() to require_once(), but the error remained
the same so I changed it back. I haven't modified Gallery's code (other
than this time), so that shouldn't be the problem...
Randy
Rick DeNatale wrote:
On 12/15/05, Randy Barlow <[EMAIL PROTECTED]> wrote:
Hi,
I have a problem with Gallery at http://www.hamlettcorp.com If you
go to the site, you will see an intro screen, and then you will be
redirected to my Gallery page. Frequently, the Gallery page gives the
following PHP error:
*Fatal error*: Cannot redeclare editfield() (previously declared in
/var/www/localhost/htdocs/gallery/util.php:27) in
*/var/www/localhost/htdocs/gallery/util.php* on line *27
*I can't make any sense of this error, because it's complaining about a
function being declared twice, but both times it's talking about the
same line of the same file! The bizarre thing is that if you refresh
the page enough, it will work. Any ideas of what's wrong?
I'm guessing here, but I'd bet that the util.php file is being
included multiple times. Php has four directives for including code.
include(filename) includes the file if it exists, with no complaint if
it doesn't.
require(filename) includes the file if it exists, and complains if it doesn't.
include_once(filename) like include but won't include the file if it's
already been pulled in before.
require_once(filename) like require but won't include an already included file.
The latter two are intended to cirumvent the kind of problem you are seeing.
I suspect that somewhere some file has either an include(util.php) or
require(util.php) and you don't get the error when this file is
processed first, and do if it's processed after another file which has
already included the file.
--
Rick DeNatale
Visit the Project Mercury Wiki Site
http://www.mercuryspacecraft.com/
--
TriLUG mailing list : http://www.trilug.org/mailman/listinfo/trilug
TriLUG Organizational FAQ : http://trilug.org/faq/
TriLUG Member Services FAQ : http://members.trilug.org/services_faq/