Jump to content

[SOLVED] PhP Redirecting AFTER Echo - Please Help!


LordLanky

Recommended Posts

Hi,

 

I'm having real trouble debugging my code - my service provider just upgraded my php version to 5.2.1 and ever since - i cant seem to do debugging the way i used to.

 

At the top of each file on my website, i have an include which sets:

 

error_reporting(E_ALL);

 

Which gives me errors, fine and dandy. However, it's a complex website with LOTS of functions. I am trying to debug a specific function the old fashioned way of echoing line numbers here and there and seeing what route they take (i'm sure there are better ways, but hey!). At the bottom of each page is a redirect depending on the outcome of the relevant functions. Usually, and intentionally, this would prevent the header("Location....") command from redirecting as 'outputs have already been given' - but for some reason now, it is redirecting!!

 

can anyone help me either a) suggest an EASY alternative method - when i mean easy, i mean doesn't take much to use. echo __LINE__; is really quick and easy to type ;),  or b) let me know how to re-break the header?!

 

Thanks much in advanced - i've been smashing my head against a wall for a day now.

LOL - they have turned on output_buffering in the php.ini. You should disable it in your own local php.ini (when php is running as a CGI application) or in a .htaccess file (when php is running as an Apache Module).

 

You should also be developing and debugging code on a local development system, not a live hosting web server.

Hi,

 

Thanks for that - I'd love to be developing locally - but a) i'm too tight to buy software ;) and b) i'm on Windows which likes to 'gently pursuade' you to use .net!

 

I'll try disabling/enabling then get back to you. Thanks for the INCREDIBLY rapid response!

Curse your expert knowledge! you make me seem lazy :)

 

Anyway, back to the question...

 

The contents of my php5.ini file are:

 

memory_limit=16M

short_open_tag = 1

upload_max_filesize = 4M

output_buffering = Off

 

 

- this now does display an echo - but on the following page - therefore it still redirects. However, there are occasions where i use a transaction page (i.e. redirect to a page that does actions - this is for security reasons - then redirect somewhere else) meaning that the echo wont appear as the transaction page lasts only a split second.

 

Any advice?

 

Thanks muchos again!

 

 

Are these script files in the same folder/path?

 

It sounds like either the php5.ini is not being used or only applies to the folder it is in (some server configurations require one in each folder, check with your host to know exactly.)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.