Question

I am using PHP to generate a csv file with a first name and second name.

On my local XAMPP server it works fine and generate this output.

Andy,Murray
Sarah,Palin
Bob,Saget

However on this 000webhost.com free webhosting site I get the following output.

    <br><table border='1' cellpadding='2' bgcolor='#FFFFDF' bordercolor='#E8B900' align='center'><tr><td><font face='Arial' size='1' color='#000000'><b>PHP Error Message</b></font></td></tr></table><br />
<b>Warning</b>:  array_walk() [<a href='function.array-walk'>function.array-walk</a>]: The argument should be an array in <b>/home/a2806375/public_html/csv.php</b> on line <b>15</b><br />
<br><table border='1' cellpadding='2' bgcolor='#FFFFDF' bordercolor='#E8B900' align='center'><tr><td><div align='center'><a href='http://www.000webhost.com/'><font face='Arial' size='1' color='#000000'>Free Web Hosting</font></a></div></td></tr></table>
<!-- Hosting24 Analytics Code -->
<script type="text/javascript" src="http://stats.hosting24.com/count.php"></script>
<!-- End Of Analytics Code -->

This is my code:

function outputCSV($data) 
        {
            $outstream = fopen("php://output", "w");


            function __outputCSV(&$vals, $key, $filehandler) 
            {
                fputcsv($filehandler, $vals); // add parameters if you want
            }
            array_walk($data, "__outputCSV", $outstream);
            fclose($outstream);
        }



        $result = $db->fetch_array($result);

        header("Content-type: text/csv");
        header("Content-Disposition: attachment; filename=guestlist.csv");
        header("Pragma: no-cache");
        header("Expires: 0");


        outputCSV($result);

Why is it doing this?

Is it because its a free hosting site and they are trying to put advertising in a CSV file?

How do I work around, I am a bit low on money atm so I cant afford a paid server. Thanks

Was it helpful?

Solution

Disable the insertion of their analytics code from their control panel:

http://members.000webhost.com/analytics.php

From: http://www.000webhost.com/forum/faq/7894-faq-frequent-ask-questions-guide.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top