euchre Posted March 12, 2008 Share Posted March 12, 2008 Hi all, newbie here... I used a free template engine that is the same as example #6 in http://sg2.php.net/manual/en/function.include.php and I run a function to call out information from a database to display the results. When the results are less than a page long (less than 30 records) the page will be displayed without errors. When there are more than 30 (offset), then I get the following error: Warning: parse() [function.include]: Failed opening '<TABLE border="0" width="98%" cellpadding="5" cellspacing="0"> <tr> <td class="header"> Quotations on 'Teaching' </td> </tr> <tr> <td class="content"> <!-- Quotes begin --> <TABLE border="0" cellpadding="5" cellspacing="0" WIDTH="100%"> <tr bgcolor="#C7DFF9"><td class="LT">One way the civilized world destroys men is by preventing them from thinking their own thoughts.</Td> <td class="RT">A.W. Tozer</td> </tr> <tr><td class="LT">We learn with difficulty, forget easily and suffer many distractions.</Td> <td class="RT">A.W. Tozer</td> </tr> <tr bgcolor="#C7DFF9"><td class="LT">Wonder rather than doubt i in /template.php on line 15 The template codes for line 15 are as follows: function parse($file) { ob_start(); include $file; $buffer = ob_get_contents(); ob_end_clean(); return $buffer; } If the template codes has problem then it should return error for any records I called up, so I do not understand why it is giving problems now and I don't know php enough to understand what is wrong with it. In the past, the pages displayed without problems until the web host upgraded PHP 4.4.8 I did a search in this forum but found nothing remotely relevant, or perhaps I am not using the right keywords? Can someone tell me what's wrong or point me to the right direction please? Any help would be most appreciated, thank you. Link to comment https://forums.phpfreaks.com/topic/95761-using-output-buffering-to-include-a-php-file-into-a-string/ Share on other sites More sharing options...
trq Posted March 12, 2008 Share Posted March 12, 2008 What exactly are you passing to this parse() function? Its expects a filename, not a string of html. Link to comment https://forums.phpfreaks.com/topic/95761-using-output-buffering-to-include-a-php-file-into-a-string/#findComment-490384 Share on other sites More sharing options...
euchre Posted March 12, 2008 Author Share Posted March 12, 2008 Thank you for replying Thorpe. It's suppose to parse the template file. Below are the codes, perhaps that will help. The background.php and quotations.php are just php files which I run functions off them. Template engine: <?php class Page { var $page; function Page($template = "template.html") { if (file_exists($template)) $this->page = join("", file($template)); else die("Error 404: Template file not found."); } function parse($file) { ob_start(); include $file; $buffer = ob_get_contents(); ob_end_clean(); return $buffer; } function replace_tags($tags = array()) { if (sizeof($tags) > 0) foreach ($tags as $tag => $data) { $data = (file_exists($data)) ? $this->parse($data) : $data; $this->page = eregi_replace("{" . $tag . "}", $data, $this->page); } else die("No tags designated for replacement."); } function output() { echo $this->page; } } ?> HTML Template file. excerpt: <html> <body> {centercol} </body> </html> Actual PHP file. excerpt: <?php session_start(); include_once("template.php"); include_once('background.php'); include('quotations.php'); $page = new Page("quotationstemplate.html"); connectqb(); quotemenu(); quote_page_title(); closedb(); displayResults(); $page->replace_tags(array( "centercol" => $quotedisplay, )); $page->output(); ?> Link to comment https://forums.phpfreaks.com/topic/95761-using-output-buffering-to-include-a-php-file-into-a-string/#findComment-490447 Share on other sites More sharing options...
euchre Posted March 13, 2008 Author Share Posted March 13, 2008 The full error msg is... Warning: parse(<TABLE border="0" width="98%" cellpadding="5" cellspacing="0"> <tr> <td class="header"> Quotations on 'Teaching'</td> </tr> <tr> <td class="content"> <!-- Quotes begin --> <TABLE border="0" cellpadding="5" cellspacing="0" WIDTH="100%"> <tr bgcolor="#C7DFF9"><td class="LT">One way the civilized world destroys men is by preventing them from thinking their own thoughts.</Td> <td class="RT">A.W. Tozer</td> </tr> <tr><td class="LT">We learn with difficulty, forget easily and suffer many distractions.</Td> <td class="RT">A.W. Tozer</td> </tr> <tr bgcolor="#C7DFF9"><td class="LT">Wonder rather than doubt is the root of knowledge.</Td> <td class="RT">Ab in /home/template.php on line 15 Warning: parse(<TABLE border="0" width="98%" cellpadding="5" cellspacing="0"> <tr> <td class="header"> Quotations on 'Teaching'</td> </tr> <tr> <td class="content"> <!-- Quotes begin --> <TABLE border="0" cellpadding="5" cellspacing="0" WIDTH="100%"> <tr bgcolor="#C7DFF9"><td class="LT">One way the civilized world destroys men is by preventing them from thinking their own thoughts.</Td> <td class="RT">A.W. Tozer</td> </tr> <tr><td class="LT">We learn with difficulty, forget easily and suffer many distractions.</Td> <td class="RT">A.W. Tozer</td> </tr> <tr bgcolor="#C7DFF9"><td class="LT">Wonder rather than doubt is the root of knowledge.</Td> <td class="RT">Ab in /home/template.php on line 15 Warning: parse() [function.include]: Failed opening '<TABLE border="0" width="98%" cellpadding="5" cellspacing="0"> <tr> <td class="header"> Quotations on 'Teaching'</td> </tr> <tr> <td class="content"> <!-- Quotes begin --> <TABLE border="0" cellpadding="5" cellspacing="0" WIDTH="100%"> <tr bgcolor="#C7DFF9"><td class="LT">One way the civilized world destroys men is by preventing them from thinking their own thoughts.</Td> <td class="RT">A.W. Tozer</td> </tr> <tr><td class="LT">We learn with difficulty, forget easily and suffer many distractions.</Td> <td class="RT">A.W. Tozer</td> </tr> <tr bgcolor="#C7DFF9"><td class="LT">Wonder rather than doubt i in /home/template.php on line 15 I only get this error when there are a lot of records to be listed, other pages with 8-15 records doesn't have this problems and the page gets displayed perfectly though. Is it the new php version that's causing the template engine to act up or is it something else? Link to comment https://forums.phpfreaks.com/topic/95761-using-output-buffering-to-include-a-php-file-into-a-string/#findComment-491024 Share on other sites More sharing options...
trq Posted March 13, 2008 Share Posted March 13, 2008 I'll say it again. Your parse() method expects a filename to include, not a string of html. Link to comment https://forums.phpfreaks.com/topic/95761-using-output-buffering-to-include-a-php-file-into-a-string/#findComment-491029 Share on other sites More sharing options...
euchre Posted March 13, 2008 Author Share Posted March 13, 2008 Sorry thorpe, but I am goober newbie here,I don't get it. I didn't write those php codes, but took them off the net somewhere and has been using them no problem for some time now. Isn't it parsing the html template file? Why else would it work for lesser records too? It seems odd to me that it had worked for about a year and suddenly just break down. Link to comment https://forums.phpfreaks.com/topic/95761-using-output-buffering-to-include-a-php-file-into-a-string/#findComment-491058 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.