Web Analytics Made Easy -
StatCounter fpdf error - CodingForum

Announcement

Collapse
No announcement yet.

fpdf error

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • fpdf error

    i'm trying to link a single entry into a pdf but everytime i run the script i get :
    Notice: Undefined variable: row_Traceps in test.php on line 11
    FPDF error: Some data has already been output, can't send PDF file
    where am i going wrong i'm still learning php.
    below is the script:
    [CODE]
    <?php require_once('Connections/traces.php');?>
    <?php
    mysql_select_db($database_traces, $traces);
    $query_rsTraceps = "SELECT * FROM traceps WHERE id = 1";
    $rsTraceps = mysql_query($query_rsTraceps, $traces) or die(mysql_error());
    $row_rsTraceps = mysql_fetch_assoc($rsTraceps);
    require ('fpdf.php');
    $pdf = new FPDF('P', 'mm', 'A4');
    $pdf -> AddPage();
    $pdf -> SetFont ('Arial','B', 10);
    $pdf -> Cell (40,10, $row_Traceps['id'] ,1);
    $pdf -> Ln(20);
    $pdf -> Cell (60,10,'Test',0,1,'C');
    $pdf -> Output();
    ?>
    [CODE]

  • #2
    Your variable on line 5 is

    $rsTraceps

    and you trying to use a variable called

    $row_Traceps['id']

    on line 11. Change one of these to be the same as the other and it should fix your issue.

    Comment


    • #3
      thank you very much, it worked

      Comment


      • #4
        please can anyone assist i'm trying to create individual documents per record to save as pdf, but doesnt get past the first record.


        <?php
        mysql_select_db($database_traces, $traces);
        $query_rsTraceps = "SELECT * FROM traceps ORDER BY sfref";
        $rsTraceps = mysql_query($query_rsTraceps, $traces) or die(mysql_error());
        $row_rsTraceps = mysql_fetch_assoc($rsTraceps);
        $i='0';
        while ($i > $row_rsTraceps) {

        $i++;
        }
        require ('fpdf.php');
        $pdf = new FPDF('P', 'mm', 'A4');
        $pdf -> AddPage();
        $pdf -> SetFont ('Arial','B', 10);
        $pdf-> Image('traceps.jpg',10,6,50);
        $pdf -> Ln(40);
        $pdf -> Cell (25,5,"Reference :");
        $pdf -> Cell (80,5,$row_rsTraceps['sfref'] ,1);

        Comment


        • #5
          You need to put your PDF generation in the loop, and fix your loop so you get the row each time instead of just once:
          PHP Code:
          <?php

          require ('fpdf.php');
          require_once(
          'Connections/traces.php');

          mysql_select_db($database_traces$traces);

          $query_rsTraceps "SELECT * FROM traceps ORDER BY sfref";
          $rsTraceps mysql_query($query_rsTraceps$traces) or die(mysql_error());

          while(
          $row_rsTraceps mysql_fetch_assoc($rsTraceps))
          {
              
          $pdf = new FPDF('P''mm''A4');
              
          $pdf->AddPage();
              
          $pdf->SetFont('Arial','B'10);
              
          $pdf->Image('traceps.jpg',10,6,50);
              
          $pdf->Ln(40);
              
          $pdf->Cell(25,5,"Reference :");
              
          $pdf->Cell(80,5,$row_rsTraceps['sfref'] ,1);
              
              
          $pdf->Output('yourfile_' $row_Traceps['id'] . '.pdf'); // use a unique name here if the id isn't available
          }

          Comment

          Working...
          X
          😀
          🥰
          🤢
          😎
          😡
          👍
          👎