Forum Moderators: coopster

Message Too Old, No Replies

Script sends php code directly to browser

         

Yamaha_R1

11:12 am on Jun 26, 2005 (gmt 0)

10+ Year Member



I installed a search script I downloaded on my main site.

What it does is opens a template (the standard page template) and processes the lines individually.

Sees its 'search' commentary line, and adds its HTML using 'print'.

Problem is, by using 'print' it prints php code right on the page - that code does NOT get processed before it is sent out.

I really need the lines before and after search to go through PHP and get processed, almost like an include. But I can't revamp the whole script to use includes, it needs to find its search line.

zRonin

1:50 pm on Jun 26, 2005 (gmt 0)

10+ Year Member



I dont exactly know what your code does, but it sounds like you could use eval [us3.php.net] to .= it to a string, and then print it when it is done. A lot of good software programs do this.

Yamaha_R1

8:33 pm on Jun 26, 2005 (gmt 0)

10+ Year Member



Looks promising, but php says 'eval' must be valid php code. Here is what I am doing.


Some HTML
about 140 lines of it.
<?
$somephp = 'Some php';
?>
More HTML

Now for the search file

while ($template_line < $numtlines)
{
if (!stristr($template[$template_line], "<!--ZOOMSEARCH-->")) {
print($template[$template_line]);
$template_line++;
}
else {
break;
}
}

So you see, its PRINTING the php code right on the page, and not evaluating it. Eval could work, but doesnt account for the HTML as well.

bennymack

8:39 pm on Jun 26, 2005 (gmt 0)

10+ Year Member



What if you enclose the search code in <?php?>

e.g.


<?php
while ($template_line < $numtlines)
{
if (!stristr($template[$template_line], "<!--ZOOMSEARCH-->")) {
print($template[$template_line]);
$template_line++;
}
else {
break;
}
}

?>

Yamaha_R1

4:40 am on Jun 27, 2005 (gmt 0)

10+ Year Member



....what?

The search file is already PHP, that is a portion of a large script.

It opens the first file, goes line by line, and 'prints' it. But 'print' literally prints the php, doesn't evaluate it.

eval can't handle the lines that arn't php. :(