can';t使用php、mysql获取pdf文件作为输出
我想使用fpdf生成PDF文件 但我得到的错误是: fpdf错误:某些数据已经输出,无法发送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());
<?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变量之前,您必须解析内容