When I create a node page containing a php function definition ( hello_world() in the example below ) I get the following error message, even though there is no function of that name in my common.inc file. The same thing happens no matter what I name the function. Why?

Fatal error: Cannot redeclare hello_world() (previously declared in /home/labornot/public_html/includes/common.inc(1816) : eval()'d code:3) in /home/labornot/public_html/includes/common.inc(1816) : eval()'d code on line 2

Thank you.

Comments

flatfeet’s picture

I'm getting the same error. It happens everytime I try to run cron jobs.

No matter what I name any function I declare in a content page using PHP, I get the following message (first function in the content page is 'getmatchsessionuid'):

Fatal error: Cannot redeclare getmatchsessionuid() (previously declared in /includes/common.inc(1342) : eval()'d code:57) in /includes/common.inc(1342) : eval()'d code on line 65

Any ideas? :D

Thanks!

harro’s picture

I now also get this error, when I try to redefine a function in template.php (in order te override the function from a module). There must be a command to unregister a function, so that you can place the right before you declare the function?

stidem’s picture

I receive this same error if I use the same function name in two different nodes. For example if I have a function called DisplayRecord in node/136 and try to use that same function name again in node/467 I will receive this error any time I try to run a cron job.

The only solutions I have found are to disable PHP filter module or be very careful to name all my functions differently from page to page. Disabling PHP filter is not reasonable option and renaming all my functions is very time consuming.

It looks like this problem has been around for a while now. Any fixes or ideas would be welcome.

Scott Idem

--
Edit
I just realized I posted a reply to Drupal 4.6.x. I am currently using Drupal 6.9.

Sholva’s picture

A workaround could be like this:

if (!function_exists("validate"))
{
function validate($email)
 {
	if(ereg("^.+@.+\\..+$", $email))
	 {
		$check = true;
	 }
	else
	 {
		$check = false;
	 }
	 return $check;
 }
}
harriska2’s picture

tracking...

Francewhoa’s picture

Possible causes and fixes at http://drupal.org/node/72099

Loving back your Drupal community result in multiple benefits for you