Hi,

Assume I start session and print data stored in session and print some html stuff at the begining of php file. Then I need to use header() to download a file afterwards.

When I do it i get this error:

Warning: Cannot modify header information - headers already sent by (output started at /var/www.....

I know I have to use ob_start() and flush but cannot apply it. I don't want to cache everything from begining untill end in my page because it is too long.

Would you please anyone show me an example?

thanks in advance

Recommended Answers

All 2 Replies

you can use the javascript window.location instead...
<?php echo "<script>window.location='yourpagehere.php'</script>"; ?>

I removed all the HTML codes between ob_start and flush. I echo-ed them. It works now.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.