0

I have a php webpage that is pulling data from my MSSQL DB and printing it to a csv file. For all of my other pages this works fine. Then I get to this one which has a result set of almost 40000. I know that isn't that large, but it doesn't seem to be working. Here's what I've got going:

Click the export to excel button:

    echo "<form action='ExportToExcel.php' method='POST'>";
    echo "<div class='CenterStuff'>";
    echo "<input type='hidden' name='ExportToExcel' value='MatTrackingAll'/>";
    echo "<input type='hidden' name='Limit' value='$limit'/>";
    echo "<input type='hidden' name='Offset' value='$offset'/>";
    echo "<input type='submit' class='button' value='Export To Excel'>";
    echo "</div></form>";

Export to Excel: I was setting the $limit and $Offset from the page calling this, but changed it to try and find what was going on.

    $offset = 0;//$_POST['Offset'];
    $limit = 27250;//$_POST['Limit'];
    $tsql = "Select Id,State,ProjectNumber,SubProjectNumber,PONumber,POLineNumber,IMLineNumber,CalloutDetails,POStatus,BlanketRelease
            ,PODateIssued,DateNeeded,POINvoiceStatus,ItemCode,ItemDesc,QuantityOrdered,QuantityReceived,DateReceived,RecordStatus
            ,ShipToLocation,DeliverToLocation,ReceiverId,TraceNumber,BOL,PackSlipNumber,POTotalAmount,POLineAmount,CostCode,RequisitionId
            ,RequisitionLineNumber,Vendor,ExchangeName,ProjectType,COECurrentProjectStatus,ReadyForService,ScheduledShipDate,MaterialComments
            ,SchedulerComments,MaterialSpecialist
            from pmdb.MaterialTracking order by State,ProjectNumber OFFSET $offset ROWS FETCH NEXT $limit ROWS ONLY";
    $hsql = "select Headings from TableHeadings where TableName = 'MaterialTracking' and Headings != 'Edit' order by ID";
    $getqueries = $conn->query($tsql);
    $result = $getqueries->fetchALL(PDO::FETCH_ASSOC);
    $filename = $_POST['ExportToExcel'];

Then I have the part where I print to the csv. I have some var_dumps in there to so that I can see where the hold up is. When I run with more than the 27250 limit then I get a blank screen and nothing happens. It does not download a file. I know that the query is good, but it stops at the $result = $getqueries->fetchALL(PDO::FETCH_ASSOC);' and thevar_dumpandecho` that I have after don't print anything.

Mike
  • 1,853
  • 3
  • 45
  • 75
  • A "500 Internal Server Error" status code (or a blank page) means that your script is throwing an error but you haven't configured PHP to display error messages. As a starting point, I suggest you edit the system-wide `php.ini` file in the computer where you develop and tweak the `error_reporting` and `display_errors` directives ([details here](http://stackoverflow.com/a/5680885/13508)). – Álvaro González Jul 12 '16 at 12:36
  • @yourcommonsense Thanks, I never would have thought to look for `white screen of death`! – Mike Jul 12 '16 at 14:04

0 Answers0