Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/58.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
can';t使用php、mysql获取pdf文件作为输出_Php_Mysql_Fpdf - Fatal编程技术网

can';t使用php、mysql获取pdf文件作为输出

can';t使用php、mysql获取pdf文件作为输出,php,mysql,fpdf,Php,Mysql,Fpdf,我想使用fpdf生成PDF文件 但我得到的错误是: fpdf错误:某些数据已经输出,无法发送pdf文件 <?php $indexcontent = mysql_real_escape_string($_GET['index']); $detailview = mysql_query("SELECT * FROM `searchengine` WHERE `indexcontent` = '$indexcontent'") or die(mysql_error());

我想使用fpdf生成PDF文件

但我得到的错误是: fpdf错误:某些数据已经输出,无法发送pdf文件

<?php
    $indexcontent = mysql_real_escape_string($_GET['index']);
     $detailview = mysql_query("SELECT * FROM `searchengine` WHERE `indexcontent` = '$indexcontent'") or die(mysql_error());
    if($result = mysql_fetch_assoc($detailview))
    {
    $filepdf = $result['maincontent'];
    require('fpdf.php');
    $pdf = new FPDF();
    $pdf->AddPage();
    $pdf->SetFont('Arial','B',16);
    $pdf->Cell(40,10,'$filepdf');
    $pdf->Output();
    }
?>

不要在单引号之间放置变量,尝试在双引号之间放置变量。

尝试以下操作:

<?php
    $indexcontent = mysql_real_escape_string($_GET['index']);
    $detailview = mysql_query("SELECT * FROM `searchengine` WHERE `indexcontent` = '$indexcontent'") or die(mysql_error());
    require('fpdf.php');
    $pdf = new FPDF();
    $pdf->AddPage();
    $pdf->SetFont('Arial','B',16);
    if($result = mysql_fetch_assoc($detailview))
    {
    $filepdf = $result['maincontent'];

    $pdf->Cell(40,10,$filepdf);

    }
    $pdf->Output();

?>


write-just$filepdfi在$result['maincontent']中有一个带有html标记的内容,而不是“$filepdf”。现在它像打印一些文本一样打印结果。我想将结果打印为普通html视图。在将其分配给$filepdf变量之前,您必须解析内容