FPDF throws errors in 000webhost

2

It worked in a localhost XAMMP, I put it in a free hosting 000webhost to try it

Warning: A non-numeric value encountered in /storage/ssd2/023/3036023/public_html/pdf/fpdf/fpdf.php on line 580

Warning: A non-numeric value encountered in /storage/ssd2/023/3036023/public_html/pdf/fpdf/fpdf.php on line 580

Warning: A non-numeric value encountered in /storage/ssd2/023/3036023/public_html/pdf/fpdf/fpdf.php on line 580

Warning: A non-numeric value encountered in /storage/ssd2/023/3036023/public_html/pdf/fpdf/fpdf.php on line 580

Fatal error: Uncaught Exception: FPDF error: Some data has already been output, can't send PDF file (output started at /storage/ssd2/023/3036023/public_html/pdf/fpdf/fpdf.php:580) in /storage/ssd2/023/3036023/public_html/pdf/fpdf/fpdf.php:271 Stack trace: #0 /storage/ssd2/023/3036023/public_html/pdf/fpdf/fpdf.php(1053): FPDF->Error('Some data has a...') #1 /storage/ssd2/023/3036023/public_html/pdf/fpdf/fpdf.php(1000): FPDF->_checkoutput() #2 /storage/ssd2/023/3036023/public_html/pdf/reporteproductos.php(32): FPDF->Output() #3 {main} thrown in /storage/ssd2/023/3036023/public_html/pdf/fpdf/fpdf.php on line 271
  

this is template.php

session_start();

require 'fpdf/fpdf.php';

class PDF extends FPDF
{
    function Header()
    {
        //$this->image('images/sen2.png', 10, 10,50);
        $this->Image('images/sen2.png' , 10, 10,50);
        $this->SetFont('Arial','B',15);
        $this->Cell(50,'','',0);
        $this->Cell(140,5,'BOUTIQUE MARIA FERNANDA',0,1,'R');
        $this->SetFont('Arial', 'B', 11);
        $this->Cell(50,'','',0);
        $this->Cell(140,5,'NIT 900354851-5',0,1,'R');
        $this->Cell(50,'','',0);
        $this->Cell(140,5,'Hoy: '.date('d-m-Y').'',0,1,'R');
        $this->Cell(50,'','',0);
        $this->Cell(140,5,'Usuario|'.$_SESSION['usuario'].'',0,1,'R');
        $this->Ln(5);   

    }

    // function Footer()
    // {
    //  $this->SetY(-15);
    //  $this->SetFont('Arial','I',8);
    //  $this->Cell(0,10,'Pagina '$this->PageNo().'/{nb}',0,0,'C');

    // }
    function Footer()
    {
        //Footer de la pagina
        $this->SetY(-15);
        $this->SetFont('Arial','I',8);
        $this->SetTextColor(128);
        $this->Cell(0,10,'Pagina '.$this->PageNo(),0,0,'C');
    }  
}?>
  

here called template, it was working in a localhost; until I put it in 000webhost.

    include 'plantilla.php';
    require 'config.php';

    $sql="SELECT * FROM  tb_productos ORDER BY cod_producto ASC ";
    $resultado = $conexion->query( $sql );

    $pdf= new PDF();
    // $pdf->AliasNbPage();
    $pdf->AddPage();
    $pdf->Cell(120,10,'Reporte de Productos ',0,1,'L');
    $pdf->SetFillColor(232,232,232);
    $pdf->SetFont('Arial','B',12);

    $pdf->Cell(25,6,'CODIGO',1,0,'C',1);
    $pdf->Cell(65,6,'NOMBRE',1,0,'C',1);

    $pdf->Cell(50,6,'PRECIO DE COMPRA',1,0,'C',1);
    $pdf->Cell(50,6,'FECHA DE REGISTRO',1,1,'C',1);

    $pdf->SetFont('Arial','',10);

    while ($row = $resultado->fetch_assoc())
    {
        $pdf->Cell(25,6,$row['cod_producto'],1,0,'C');
        $pdf->Cell(65,6,utf8_decode($row['descripcion']) ,1,0,'C');

        $pdf->Cell(50,6,$row['precio_compra'],1,0,'C');
        $pdf->Cell(50,6,$row['fecha_registro'],1,1,'C');
    }

    $pdf->Output();?>
    
asked by STMENDOZZA 27.09.2017 в 19:58
source

1 answer

1

when they go through these types of problems you should check two things

  • The version of PHP installed on the server is the same as your computer's version.

    • Solution : Update one of the two environments (Sometimes it is easier to update the server's other ... NO)
  • The common folder error where you type PHP does not have permission with your user.

    • Solution : when doing the output, the source code must write in a path give permissions 644 and the owner is the user www-data (command chown )
  • answered by 27.09.2017 / 20:30
    source