423,850 Members | 1,074 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,850 IT Pros & Developers. It's quick & easy.

parse error or infinite loop? a blank screen, yet the php error logis empty

P: n/a

Imagine a template system that works by getting a file, as a string, and
then putting it through eval(), something like this:


$formAsString = $controller->command("readFileAndReturnString", $formName);
// 06-22-07 - the next commands try to import all the functions that the
form
// contains, so we don't get "Fatal Error: Undefined Function".
$arrayOfNeededFunctions =
$controller->command("matchAllPhpFunctionsInString", $formAsString);
$arrayOfTrueAndFalseResults = $controller->command("loopArray",
$arrayOfNeededFunctions, "getNeededFunctionsEach");

// 06-22-07 - (must end php or I get errors)
$phpEnd = "?";
$phpEnd .= "";
$formAsString = $phpEnd.$formAsString;

echo "<p>in importForm: <hr$formAsString";

eval($formAsString);

The echo statement, which I just put there, shows the string about like
what I'd expect. Yet, on this page, I get a blank:

http://www.cyberbitten.com/my_privat...ples_posts.htm

A blank in the middle of the page, where I am trying to import a
sub-template. Normally, if I get blank, it means that there is a parse
error in the file being included. And yet, if I ssh to the server and
examine the error log, it is empty. If I deliberately invoke an error on
another page (in this case, weblog.php), then that appears in the error
log, but no parse error does:

root@ldc310:/usr/local/bin# tail php_errors
[16-Jun-2008 20:06:42] PHP Warning: mime_magic: type regex
BEGIN[[:space:]]*[{] application/x-awk invalid in Unknown on line 0
[16-Jun-2008 20:07:03] PHP Parse error: syntax error, unexpected
T_STRING in /var/www/vhosts/cyberbitten.com/httpdocs/weblog.php on line 68
[16-Jun-2008 20:07:05] PHP Parse error: syntax error, unexpected
T_STRING in /var/www/vhosts/cyberbitten.com/httpdocs/weblog.php on line 68
[16-Jun-2008 20:07:07] PHP Parse error: syntax error, unexpected
T_STRING in /var/www/vhosts/cyberbitten.com/httpdocs/weblog.php on line 68
[16-Jun-2008 20:07:07] PHP Parse error: syntax error, unexpected
T_STRING in /var/www/vhosts/cyberbitten.com/httpdocs/weblog.php on line 68

So, what else could it be? My next thought was that it was an infinite
loop, but there are no loops on the page, only a call to my loop()
command, which has protections against infinite looping.

What would allow that string to echo to the screen, yet have the eval()
not generate anything for the screen, and there be no error in the error
log?


Jun 27 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Lawrence Krubner wrote:
>
Imagine a template system that works by getting a file, as a string, and
then putting it through eval(), something like this:


$formAsString = $controller->command("readFileAndReturnString", $formName);
// 06-22-07 - the next commands try to import all the functions that the
form
// contains, so we don't get "Fatal Error: Undefined Function".
$arrayOfNeededFunctions =
$controller->command("matchAllPhpFunctionsInString", $formAsString);
$arrayOfTrueAndFalseResults = $controller->command("loopArray",
$arrayOfNeededFunctions, "getNeededFunctionsEach");

// 06-22-07 - (must end php or I get errors)
$phpEnd = "?";
$phpEnd .= "";
$formAsString = $phpEnd.$formAsString;

echo "<p>in importForm: <hr$formAsString";

eval($formAsString);

The echo statement, which I just put there, shows the string about like
what I'd expect. Yet, on this page, I get a blank:

http://www.cyberbitten.com/my_privat...ples_posts.htm
A blank in the middle of the page, where I am trying to import a
sub-template. Normally, if I get blank, it means that there is a parse
error in the file being included. And yet, if I ssh to the server and
examine the error log, it is empty. If I deliberately invoke an error on
another page (in this case, weblog.php), then that appears in the error
log, but no parse error does:

root@ldc310:/usr/local/bin# tail php_errors
[16-Jun-2008 20:06:42] PHP Warning: mime_magic: type regex
BEGIN[[:space:]]*[{] application/x-awk invalid in Unknown on line 0
[16-Jun-2008 20:07:03] PHP Parse error: syntax error, unexpected
T_STRING in /var/www/vhosts/cyberbitten.com/httpdocs/weblog.php on line 68
[16-Jun-2008 20:07:05] PHP Parse error: syntax error, unexpected
T_STRING in /var/www/vhosts/cyberbitten.com/httpdocs/weblog.php on line 68
[16-Jun-2008 20:07:07] PHP Parse error: syntax error, unexpected
T_STRING in /var/www/vhosts/cyberbitten.com/httpdocs/weblog.php on line 68
[16-Jun-2008 20:07:07] PHP Parse error: syntax error, unexpected
T_STRING in /var/www/vhosts/cyberbitten.com/httpdocs/weblog.php on line 68

So, what else could it be? My next thought was that it was an infinite
loop, but there are no loops on the page, only a call to my loop()
command, which has protections against infinite looping.

What would allow that string to echo to the screen, yet have the eval()
not generate anything for the screen, and there be no error in the error
log?


Okay, I worked it out. I was using double quotes inside of double quotes
inside of the PHP code, in an SQL query. A stupid mistake. But I am
surprised that when I called eval() on this string, no error appeared in
the PHP error log. Instead, I solved this problem by finding the last
working version of this file in Subversion, and comparing it to the
first non-working version of the file. Then my mistake jumped out at me.
Thank god for Subversion.

Jun 27 '08 #2

P: n/a
Greetings, Lawrence Krubner.
In reply to Your message dated Tuesday, June 17, 2008, 07:04:51,
the PHP error log. Instead, I solved this problem by finding the last
working version of this file in Subversion, and comparing it to the
first non-working version of the file. Then my mistake jumped out at me.
Thank god for Subversion.
Get a good editor with syntax highlighting.
Then your mistake will just light through the code till you find and kill it.
--
Sincerely Yours, AnrDaemon <an*******@freemail.ru>

Jun 27 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.