嘿大家我正在使用TCPDF库来制作PDF。 我收到这个错误:
“警告:mysqli_fetch_array()要求参数1为mysqli_result,boolean给出” “TCPDF错误:某些数据已经输出,无法发送PDF文件”
所以我的问题是,它没有从我的表tbl_mascota获取数据并在td标签中“发布”它
<?php
ob_start();
include('lib/tcpdf/tcpdf.php');
include('controller/conn.php');
$con = get_con();
$query = 'SELECT * FROM tbl_mascota WHERE id_mascota = 1001';
$resultado = mysqli_query($con,$query);
$fila = mysqli_fetch_array($resultado);
//$nombre = $_GET['nombre'];
// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetTitle('Reporte:'.' '.rand(1,100));
$pdf->SetSubject('TCPDF Tutorial');
$pdf->SetKeywords('TCPDF, PDF, example, test, guide');
// set default header data
$pdf->SetHeaderData(PDF_HEADER_LOGO,0, PDF_HEADER_TITLE.'', PDF_HEADER_STRING, array(0,64,255), array(0,64,128));
// set header and footer fonts
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
// set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
// set some language-dependent strings (optional)
if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
require_once(dirname(__FILE__).'/lang/eng.php');
$pdf->setLanguageArray($l);
}
// ---------------------------------------------------------
// set default font subsetting mode
$pdf->setFontSubsetting(true);
// Set font
// dejavusans is a UTF-8 Unicode font, if you only need to
// print standard ASCII chars, you can use core fonts like
// helvetica or times to reduce file size.
$pdf->SetFont('dejavusans', '', 14, '', true);
// Add a page
// This method has several options, check the source code documentation for more information.
$pdf->AddPage();
// set text shadow effect
$pdf->setTextShadow(array('enabled'=>true, 'depth_w'=>0.2, 'depth_h'=>0.2, 'color'=>array(196,196,196), 'opacity'=>1, 'blend_mode'=>'Normal'));
function mid(){
$this->Cell('Reporte'.rand(1,50));
}
$html = <<<EOF
<style>
.tbl{
width: 75%;
background-color: #279446;
}
th{
text-align: center;
}
td{
background-color: #DEDEDE;
border: 2px solid black;
}
.ds{
hei
text-align: center;
background-color: #279446;
}
</style>
<div class="ds">Reporte de la Mascota - TechVet </div>
<br>
<CENTER>
<table class="tbl">
<tr>
<th></th>
<th></th>
<th>Imagen</th>
</tr>
<tr>
<td>Nombre:</td>
<td><?php echo fila['nombre']; ?></td>
</tr>
<tr>
<td>Raza:</td>
<td> </td>
</tr>
<tr>
<td>Sexo:</td>
<td> </td>
</tr>
<tr>
<td>Peso</td>
<td> </td>
</tr>
<tr>
<td>Edad:</td>
<td> </td>
</tr>
<tr>
<td>Color de Pelo:</td>
<td> </td>
</tr>
<tr>
<td>Dueños:</td>
<td> </td>
</tr>
</table>
</CENTER>
<br>
<div class="ds">Comentarios - Prosigna </div>
EOF;
// Print text using writeHTMLCell()
$pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true);
// ---------------------------------------------------------
// Close and output PDF document
// This method has several options, check the source code documentation for more information.
$pdf->Output('extra_filees/prueba.pdf', 'I');
//============================================================+
// END OF FILE
//============================================================+