Page redirection problem?

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
AMCH
Forum Commoner
Posts: 31
Joined: Sun Mar 30, 2008 4:39 pm

Page redirection problem?

Post by AMCH »

Hi,

I am having a problem that appears to be occurring randomly and I am not sure exactly why. When certain pages that are php handler pages are being navigated to upon form submission they are occasionally showing as a completely white page.

The pages seem to load and then are “done” loading as far as the browser is concerned. They are supposed to run and then after doing the code on them they are supposed to redirect the user to other pages using the “header” and in some cases “META” method of redirection.

90% of the time it actually works perfectly by redirecting the user to the required page but occasionally there is the above stated problem.

Since it appears to be occurring randomly I have thought that the trigger stimulus must be random too, such as connection speed for instance?

Can anyone make any suggestions as to what might be causing this problem?

Much Appreciated
AMCH :banghead:
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Page redirection problem?

Post by Christopher »

You probably have PHP error and error_reporting is turned off. Either check the logs or turn error_reporting On
(#10850)
AMCH
Forum Commoner
Posts: 31
Joined: Sun Mar 30, 2008 4:39 pm

Re: Page redirection problem?

Post by AMCH »

arborint wrote:You probably have PHP error and error_reporting is turned off. Either check the logs or turn error_reporting On
Thanks for replying.

Error reports are turned on. If there were errors then it would never work as nothing is actually changing as far as the code is concerned since something that works one second fails to work the next despite all variables being identical etc. It really is random. :banghead:

Any more suggestions?

With thanks in anticipation.
AMCH :crazy:
User avatar
EverLearning
Forum Contributor
Posts: 282
Joined: Sat Feb 23, 2008 3:49 am
Location: Niš, Serbia

Re: Page redirection problem?

Post by EverLearning »

I once got white pages using

Code: Select all

header("Location: $url")
when $url was for some reason undefined.
These are questions that come to my mind:
Do you have "exit()" after "header()", to prevent further execution of code?
Are you sure that white pages showing are completely random? Maybe they appear on some specific combinations of entered form data (Just reread your post, and you said that you're using identical data so I guess it's not that :().
Have you looked in php error log, maybe there is something there?
Also, you said redirect is done sometimes using "header" and sometimes "META" method. Does you problem appear when you're using "header" or "META"?
kryles
Forum Contributor
Posts: 114
Joined: Fri Feb 01, 2008 7:52 am

Re: Page redirection problem?

Post by kryles »

have you used print or echo to make sure you are where you expect to be? Misleading else if's can lead you to something with no code and thus white. At least it has happened to me before lol
AMCH
Forum Commoner
Posts: 31
Joined: Sun Mar 30, 2008 4:39 pm

Re: Page redirection problem?

Post by AMCH »

EverLearning wrote:I once got white pages using

Code: Select all

header("Location: $url")
when $url was for some reason undefined.
These are questions that come to my mind:
Do you have "exit()" after "header()", to prevent further execution of code?
Are you sure that white pages showing are completely random? Maybe they appear on some specific combinations of entered form data (Just reread your post, and you said that you're using identical data so I guess it's not that :().
Have you looked in php error log, maybe there is something there?
Also, you said redirect is done sometimes using "header" and sometimes "META" method. Does you problem appear when you're using "header" or "META"?
Hi, thanks for reply.

I do use die() after header() to prevent further execution. The problem seems to occur when using both header and META.

Any more ideas?

Much appreciated guys! Thanks for all replies.

:banghead:
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Re: Page redirection problem?

Post by s.dot »

You cannot use header('Location: ...') in php and meta refresh in HTML, if I am understanding you correctly. You have to do one or the other. :)
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
AMCH
Forum Commoner
Posts: 31
Joined: Sun Mar 30, 2008 4:39 pm

Re: Page redirection problem?

Post by AMCH »

scottayy wrote:You cannot use header('Location: ...') in php and meta refresh in HTML, if I am understanding you correctly. You have to do one or the other. :)
Hi,

Thanks for reply.

I have used them on different scripts, not on the same one. :?

:| :banghead: :crazy:

lol :D
User avatar
EverLearning
Forum Contributor
Posts: 282
Joined: Sat Feb 23, 2008 3:49 am
Location: Niš, Serbia

Re: Page redirection problem?

Post by EverLearning »

Have you tested this on different browsers, different servers? Maybe it's something specific to your environment that's causing the problem.
AMCH
Forum Commoner
Posts: 31
Joined: Sun Mar 30, 2008 4:39 pm

Re: Page redirection problem?

Post by AMCH »

EverLearning wrote:Have you tested this on different browsers, different servers? Maybe it's something specific to your environment that's causing the problem.
I have tested on IE and Moz FF, same problem on both. I also noticed that occassionally the phpbb3 forum that I setup on the same server is doing the same thing, which would suggest it's nothing to do with my code. I do not know if any of my users experience the problem because we are testing at the moment but time will tell.

Could a server related issue cause this?

Could a weak connection in my office cause this on my local machine?

:|

Cheers for help
AMCH
User avatar
EverLearning
Forum Contributor
Posts: 282
Joined: Sat Feb 23, 2008 3:49 am
Location: Niš, Serbia

Re: Page redirection problem?

Post by EverLearning »

It seems to be a server issue, by your account.
There is a possibility that PHP process has exhausted its available memory(I think that should be in the PHP error log, but I'm not sure).
You can try using Live HTTP headers FF extension, to monitor the HTTP headers flow to see if everything is as it should be.
User avatar
EverLearning
Forum Contributor
Posts: 282
Joined: Sat Feb 23, 2008 3:49 am
Location: Niš, Serbia

Re: Page redirection problem?

Post by EverLearning »

Also look through your web server logs.
Post Reply