Recently any of my nodes with embedded PHP code won't run. I get an error no matter what the PHP is. This is the error.

Parse error: syntax error, unexpected '>' in /home/mynlada/public_html/includes/common.inc(1355) : eval()'d code on line 1

Even with this code:

<?php
print "hello";
?>

I've been going through and disabling modules to see if this would help, but nothing seems to help. I'm wondering if it started happening when I upgraded to version 5.10.

I'm not really sure what to do next. Has anyone else experienced this problem? Any ideas on what I can do to solve this problem? Any help would be greatly appreciated.

Thanks,
tc

Comments

toddchris’s picture

Here's an update. I disabled every module possible and it still doesn't work.

Also, I created a test installation with a fresh install of 5.10 and of course the PHP code works there, then I copied the old database over the top of the new one. The site runs, but now I get the PHP error, so the problem seems to be the database.

Any idea where in the database this problem might reside?

chx’s picture

If you already code PHP then why not just open up common.inc and read the code? It's quite easy. The error message tells you the very line, it's less than 30 characters of highly readable code.
--
The news is Now Public | Drupal development: making the world better, one patch at a time. | A bedroom without a teddy is like a face without a smile. |

--
Drupal development: making the world better, one patch at a time. | A bedroom without a teddy is like a face without a smile.

toddchris’s picture

To say I code PHP would be quite a stretch. lol I have coded in other languages in the past, but am totally new to PHP.

I have opened up common.inc and looked at the code, but it doesn't make sense that there's a problem with the code. The code works fine in my other installations and apparently for the rest of the world. It's only with this one database where it seems to have a problem.

My understanding of the code is that it uses eval() to make sure the code is valid.

function drupal_eval($code) {
  ob_start();
  print eval('?>'. $code);
  $output = ob_get_contents();
  ob_end_clean();
  return $output;
}

And I don't understand how the eval() part really works, especially the "print eval('?>'. $code);" line. Apparently that somehow makes sure the code has valid start and end tags, but my test code has that.

How much more basic can I get than . . .

<?php
print  "hello";
?>

I'm just really at a loss as to what to do.

tc

buginblue’s picture

Did you ever find a solution to these errors? I have a very similar problem - drupal_eval is reporting php errors but how do you know where the error actually is? Many thanks