0

I am trying to create pdf files using FPDF. everything works fine on localy but as soon as I moved everything to the server its not working anymore. I am receiving the following error message: FPDF error: Some data has already been output, can't send PDF file (output started at /users/simplesystems/www/fpdf/pdf_rechnungen/Rechnungen.php:81)

this is the code in the mentioned path

<?php
error_reporting(E_ALL);
include('rechnungenclass.php');
$rechnungen = new rechnungenclass();
$rechnungen->rechnungenausgeben();
$rechnungen->rechnungenhinzufuegen();
?> 

I tried deleting all the echos --> but still the same issue. works perfectly locally.

Can you please help me?

**update --> code of Rechnungen.php

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
        <meta name="description" content="">
        <meta name="author" content="">
        <link rel="icon" href="favicon.ico">
        <title>Rechnungen</title>
        <!-- Bootstrap core CSS -->
        <link href="../../navbar/dist/css/bootstrap.min.css" rel="stylesheet">
        <!-- Custom styles for this template -->
        <link href="../../navbar/navbar.css" rel="stylesheet">
        <script src="../../navbar/assets/js/ie-emulation-modes-warning.js"></script>
         </head>
    <body>
        <div class="container">
            <!-- Static navbar -->
            <nav class="navbar navbar-default">
                <div class="container-fluid">
                    <div class="navbar-header">
                        <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
                            <span class="sr-only">Toggle navigation</span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                        </button>
                        <a class="navbar-brand" href="#">SimpleSystems</a>
                    </div>
                    <div id="navbar" class="navbar-collapse collapse">
                        <ul class="nav navbar-nav">
                            <li><a href="../../navbar/index.html">Home</a></li>
                            <li><a href="../../php/reisegruppe.php">Reisen</a></li>
                            <li><a href="../../php/teilnehmer.php">Teilnehmer</a></li>
                            <li class="active"><a href="Rechnungen.php">Rechnungen</a></li>
                            <li class="dropdown">
                                <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
                                <ul class="dropdown-menu">
                                    <li><a href="#">Action</a></li>
                                    <li><a href="#">Another action</a></li>
                                    <li><a href="#">Something else here</a></li>
                                    <li role="separator" class="divider"></li>
                                    <li class="dropdown-header">Nav header</li>
                                    <li><a href="#">Separated link</a></li>
                                    <li><a href="#">One more separated link</a></li>
                                </ul>
                            </li>
                        </ul>
                        <ul class="nav navbar-nav navbar-right">
                        <!--  <li class="active"><a href="./">Default <span class="sr-only">(current)</span></a></li>
                          <li><a href="navbar-static-top">Static top</a></li>
                          <li><a href="navbar-fixed-top">Fixed top</a></li>-->
                        </ul>
                    </div><!--/.nav-collapse -->
                </div><!--/.container-fluid -->
            </nav>  
            <div class="jumbotron">    
                <h3> Rechnungen erfassen</h3>
<?php
ob_start();
require ('rechnungenclass.php');
$rechnungen = new rechnungenclass();
$rechnungen->rechnungenausgeben();
$rechnungen->rechnungenhinzufuegen();
ob_end_flush();
?>
            <h3><u> Rechnungen hinzufuegen </u></h3>      
                <form method="post" action="">
                    <p><label>Rechnung Beschreibung:<br><input type="text" name="rechnungen_beschreibung"></label></p>
                    <p><label>Betrag:<br><input type="text" name="Betrag"></label></p>
                    <p><label>Reisegruppe ID:<br><input type="text" name="FK_reisegruppe_id"></label></p>    
                    <input type="submit" name="form0" value=Hinzufuegen>
                </form></br>
                </body>
                </html>
  • Read the linked dupe. Different specific problem, but will fix your problem. – Marc B Dec 01 '15 at 15:26
  • thx marc.. I checke the thread you posted and tried couple of things like removing white spaces, deleting echos and adding the lines error_reporting(E_ALL); ini_set("display_errors", 1); could you please help? – simple_systems Dec 01 '15 at 16:39
  • the error message tells you where output was started. start working from there. – Marc B Dec 01 '15 at 16:42
  • line 81 mentioned in the error message is the first line – simple_systems Dec 01 '15 at 16:54
  • check for hidden/invisible characters. **ANYTHING** that's not inside `` tags counts as output in PHP. – Marc B Dec 01 '15 at 16:58
  • I have been checking it for couple of hours now,, I checked for whitespaces in all the "require" files.. I will upload the code of the page.. maybe you will see the error which I am not seeing.. thx for the help – simple_systems Dec 01 '15 at 21:12
  • I have updated the post with the code.. thx for all the help – simple_systems Dec 01 '15 at 21:19
  • uh, **ALL** of that html before your ` – Marc B Dec 01 '15 at 21:20
  • ah ok thx for the quick response.. do you have a suggestion how I can avoid/solve it? within the html code, using the php code I am showing some data from the database and then creating pdf files using fpdf.. – simple_systems Dec 01 '15 at 21:40
  • move the pdf generating stuff to the top of the script, so it runs/exit before ANY output is performed, – Marc B Dec 01 '15 at 21:42

0 Answers0