cancel
Showing results for 
Search instead for 
Did you mean: 

scripts not running since the move to new server

Marteknet
Grafter
Posts: 577
Registered: 13-10-2007

scripts not running since the move to new server

I need advice on scripts not running since the move to new server.
they used to work just fine but now return errors. see below.

heres the error's output.

#!/usr/local/bin/php4 peter@martek.force9.co.uk Peter C Martin
Warning: Cannot modify header information - headers already sent by (output started at /files/home/martek/php-bin/pstats/pstats.php:2) in /files/home/martek/php-bin/pstats/pstats.php on line 94

Warning: Cannot modify header information - headers already sent by (output started at /files/home/martek/php-bin/pstats/pstats.php:2) in /files/home/martek/php-bin/pstats/pstats.php on line 95

Warning: Cannot modify header information - headers already sent by (output started at /files/home/martek/php-bin/pstats/pstats.php:2) in /files/home/martek/php-bin/pstats/pstats.php on line 96

Warning: Cannot modify header information - headers already sent by (output started at /files/home/martek/php-bin/pstats/pstats.php:2) in /files/home/martek/php-bin/pstats/pstats.php on line 97

Warning: Cannot modify header information - headers already sent by (output started at /files/home/martek/php-bin/pstats/pstats.php:2) in /files/home/martek/php-bin/pstats/pstats.php on line 98

Warning: Cannot modify header information - headers already sent by (output started at /files/home/martek/php-bin/pstats/pstats.php:2) in /files/home/martek/php-bin/pstats/pstats.php on line 99


Here is the code that the errors relate to ...

header('Content-Type: text/html; charset='.CONF_CHARSET);
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');

anyone got any idea's why this is happening, because as i said they used to work without errors.
6 REPLIES
N/A

scripts not running since the move to new server

Do you have the scripts in the cgi-bin/ folder? If so, you're not really meant to so you should move them out of there and remove the #!/usr/local/bin/php line.
Marteknet
Grafter
Posts: 577
Registered: 13-10-2007

not now in the cgi-bin

They were in the cgi-bin but since the move to the new server php will not run.

They are now in root/php-bin/, I made the php-bin in the root folder to house all php scripts in for tidyness.

The point is the scripts no longer run correctly while out-side the cgi-bin. What path has changed to cause the errors i am now getting. please bear in mind i do not have records or data on what the paths used to be while the scripts were in the cgi-bin so can't compare them with the new paths to find which one's i need to amend to make the scripts run with-out generating errors.

Any help or advice you be very welcome.
Marteknet
Grafter
Posts: 577
Registered: 13-10-2007

Sill not working without errors

I have removed the #!/usr/local/bin/php line.
The script isn't in the cgi-bin and the errors still there they are new since the script was moved out of the cgi-bin.
have you any idea why they ran ok in the cgi-bin but will not now they have been moce out of it.

Regards Peter.
N/A

scripts not running since the move to new server

If you are using header() you shouldn't have any blank lines (or lines with text) before the header() lines. If you provide the errors I may be able to advise more.
Marteknet
Grafter
Posts: 577
Registered: 13-10-2007

No blank lines

Yes you are rigth blank lines will affect this and generate an error but i didn't have any blank lines and each line was terinated correctly.

I have found a fix for this. it seems the version of php now being used isn't quite the same as what was being used before or that it has been configered to affect how tight error reporting is handled. what was happening was that some code was being sent before the header() command was parsed. and because the way things are now set up it's less tollerant and was writing back errors. the way to stop this happening is to buffer the output till after the header() commands are read by the servers php enterperater.

For other people who wish to know how to fix this read on.

add this line at the start of code before any output but after the <?

ob_start();

your code goes here right up to just after the last header() command.

then after the header() comand put the next line in

ob_end_flush();

easy when you understand whats happening and causing the errors, but it took a while to figure this one out as i didn't get any pointers from force9 on this, they just said some paths were changed and the server and php were configered differant now.

Thanks to all the people who answered my cry for help.
N/A

scripts not running since the move to new server

Ah, yes, display_errors etc. is now on in the configuration, as it was annoying people that it wasn' t on Smiley