Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Jul 2005
    Posts
    62
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Headers sent woes : ob_start()??

    Hey Gang,

    Am getting the following error :
    Warning: Cannot modify header information - headers already sent by (output started at c:\program files\easyphp1-8\www\collotype\materialsregister\template.inc:622) in c:\program files\easyphp1-8\www\collotype\includes\functions.inc.php on line 1415

    and i haven't figured how to use ob_start() yet.
    any ideas?

    the code for the query works fine if I remove the headers.
    I wish to make the browser compile and 'save' the csv contents to the desktop etc.

    PHP Code:
    function exportCSV () {
        
    ob_start();

    header("Content-type: application/octet-stream");
    header("Content-disposition: attachment; filename=Materials-".date("d-m-Y").".csv");
    header("Pragma: no-cache");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("Expires: 0");

    $query = ("SELECT *, aupapercategory.paperCategory FROM ausapapersummary
    LEFT JOIN aupapercategory ON ausapapersummary.paperCategoryId = aupapercategory.papercategoryId
    LEFT JOIN austock ON ausapapersummary.stockId = austock.StockId
    LEFT JOIN auadhesive ON ausapapersummary.adhesiveId = auadhesive.adhesiveId
    LEFT JOIN auliner ON ausapapersummary.linerId = auliner.linerId
    LEFT JOIN ausupplier ON ausapapersummary.supplierId = ausupplier.supplierId
    LEFT JOIN ausuitability ON ausapapersummary.suitabilityFoil = ausuitability.suitabilityId
    LEFT JOIN admins ON ausapapersummary.ausapaperUserId = admins.id WHERE 1=1"
    );

    // Execute SQL Query
    $result mysql_query($query);   

    // Error SQL Query
    if(!$resulterror_message(sql_error());

    // While loop for SQL output
    while($query_data mysql_fetch_array($result)) {
    $summaryId $query_data['summaryId'];
    $paperCategoryId $query_data['paperCategoryId'];
    $colloPaperName $query_data['colloPaperName'];
    $manufacturerName $query_data['manufacturerName'];
    $cpl $query_data['cpl'];

    echo 
    "$colloPaperName,""$paperCategory,""$manufacturerName,""$supplier,""$availability,""$features,""$limitations,""$productExamples\n";

        }


  • #2
    New Coder
    Join Date
    Sep 2005
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Sounds as if some sort of headers are being sent before you use ob_start(). Try moving it to the very top of your script and see if it changes anything.

  • #3
    Regular Coder
    Join Date
    Aug 2004
    Posts
    280
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i have similar problem: i have the headers at the very beginning of the script, but warning is shown that i started sending data at line 1 (ONE, yes!)

    code (copy-pasted):

    <?php

    //ob_start('i');
    //header('Cache-Control: no-store, no-cache, must-revalidate');
    header('Cache-Control: no-store, no-cache, must-revalidate',true);
    header('Connection: Keep-Alive',true);
    header('stupid: yes');
    //session_start();

    code going on...


    if i call ob_start() at the begiinning, does not help

  • #4
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    chances are you have a space or some kind of code before the opening <?php tag.

    You chould call ob_start() at the VERY TOP of the page, before anything else, before you even type a space.. Then at the very bottom of the page you can use ob_end_flush(); to flush (send) the entire contents of the buffer.

  • #5
    Regular Coder
    Join Date
    Aug 2004
    Posts
    280
    Thanks
    0
    Thanked 0 Times in 0 Posts
    nono, my script STARTS with that code i wrote, so the first characters in the script are supposed to be '<?php'

    i made this file with dw mx.. could be any problems with encoding?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •