headers

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
cardi777
Forum Commoner
Posts: 54
Joined: Sun Mar 29, 2009 4:26 am

headers

Post by cardi777 »

Hi all. This forum has been soooo helpful. I have been using it for ages and there is a real wealth of knowledge and understanding. I keep throwing what i think are curly quesitons, and people actually respond!!?

I have this wierd issue. Here goes...

There is an "export csv from mysql" function, and an "import csv to mysql function". They both work fine.

When I export csv, it is a form which shoots to a php file that makes the file for me. Here are the headers at the end of it that i think may be relevant...

Code: Select all

   
header('Cache-Control: no-cache, must-revalidate, post-check=0, pre-check=0');
header('Content-Length: ' . strlen($out));
header('Content-type: text/x-csv');
header('Content-Disposition: attachment; filename=export_'.$name.'_'.date('Ymd').'_'.date('His').'.csv');
echo $out;
exit;
 


I then get a promt to save my file - and its all good! The page itself doesn't appear to change at all.

IF if then import a csv right after doing this, which is an upload field on the same page which shoots off to the php import page, i get the prompt again to download the exported csv! And the csv i was trying to import took place perfectly.

The import and export work fine indipendant of eachother, but when i export THEN import one after the other i get prompted to download the exported csv again.... so I figure that its something to do with the header? Or the:

Code: Select all

echo $out;
Any help? a bit puzzled.

Cheers,
Doug
Post Reply