tags:

views:

48

answers:

4

I tried using xampp lite portable in my flash drive so that I could bring the server anywhere. But I always get an error when using xampp. This error in particular:

Warning: Cannot modify header information - headers already sent by (output started at /path/to/geeklog/public_html/blabla.php:581) in /path/to/geeklog/public_html/system/lib-blablab.php on line 180

I don't know why I'm getting this error. But when I use wampserver. There's really no problem. And I don't get any errors. What do I need to do to solve this when I'm using xampp. Is there a portable version of wamp

+3  A: 

Is it possible there's a little bitty bit of whitespace outside of the PHP tags in blabla.php line 581? I bet there is.

See, if you have anything outside of PHP tags, that is sent to the browser. And once something has been sent to the browser, you can't send headers (like the sessionID cookies!) anymore.

The problem is likely not XAMPP, but your PHP code as you put it on the flash drive.

Borealid
+1  A: 

The difference you're seeing between environments is most almost certainly a difference in the configuration.

One of two things is happening on the server that isn't emiting Warnings:

1) Output buffering is on by default

2) error_reporting and/or display_errors is set so you're just not seeing the warnings. But if this were the case, your headers still wouldn't get set, so it's probably #1

You can check these settings by looking at the output from phpinfo()

Output buffering, when enabled, buffers any output (regular content not inside tags, anything you echo or print(), etc) on the server and then sends it to the client in one shot.

I'd poke around in your portable version, find php.ini, and try turning output buffering on. Alternatively, you can turn output buffering on at runtime by sticking ob_start() near the top of your script.

timdev
A: 

To ensure your error reporting level is the same across environments, you can set it in your application using error_reporting() and ini_set('display_errors', 1)

Also check your .php files for any whitespace before the opening tag and after the closing tag.

In addition to the points mentioned above, ensure you are not outputting anything before the headers are set, for example the following code would produce an error similar to the one you are receiving:

echo 'Hello, World';
header('Location: http://www.somesite.com');
BenTheDesigner
A: 

The error states: output started at /path/to/geeklog/public_html/blabla.php:581, so I would start there. You need to send all headers before outputting anything, this includes whitespace as mentioned by others here.

Peter Kruithof