私はmysqlテーブルからデータを取得するform.phpファイルを持っています。 form.phpDOMPDFが動作しない、エラーが発生する
<?php
if(mysql_num_rows($sql)==0){
?>
<table>
<tr>
<td>1.</td>
<td>America</td>
<tr>
</table>
<a href="pdf.php" target="_blank">Export as PDF</a>
<?php
} else {
?>
<table>
<tr>
<td>1.</td>
<td>India</td>
<tr>
</table>
<a href="pdf.php" target="_blank">Export as PDF</a>
<?php
}
?>
そしてpdf.php
require_once("dompdf/dompdf_config.inc.php");
ob_start();
$html = file_get_contents('form.php');
$dompdf = new DOMPDF();
date_default_timezone_set('Asia/Kolkata');
$tym = date('g:i s');
$filename = 'FAA-8130_3_'.$tym;
$dompdf->load_html($html);
ob_end_flush();
$dompdf->render();
$dompdf->stream($filename. ".pdf", array("Attachment" => 0));
私はPDFファイルとしてエクスポートしようとすると、それがエラーを与えている...
Fatal error: Call to a member function prepend_child() on a non-object in C:\wamp\www\path\to\dompdf\include\frame_tree.cls.php on line 231
なぜそれが起こっているのか理解できませんでした。私はthis、thisおよびthisを見ましたが、解決に失敗しました。
file_get_contents()はファイルの内容を返しますが、PHPファイルは実行されません。 –
@HalayemAnis次に私は何をすべきですか? – Raj
内容を分離する:ビジネスとプレゼンテーション..また、mysql_ *を使用して停止する代わりにmysqli_ *またはPDOを使用する –