首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我无法获得pdf文件作为输出使用php,mysql

问我无法获得pdf文件作为输出使用php,mysql
EN

Stack Overflow用户
提问于 2015-12-24 17:34:45
回答 2查看 44关注 0票数 0

我想用fpdf生成PDF文件

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

代码语言:javascript
复制
<?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();
    }
?>
EN

回答 2

Stack Overflow用户

发布于 2015-12-24 18:55:08

不要把变量放在单引号之间,尽量放在双引号之间。

票数 0
EN

Stack Overflow用户

发布于 2015-12-24 19:02:23

试试这个:

代码语言:javascript
复制
<?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();

?>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34450518

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档