Forum Moderators: coopster

Message Too Old, No Replies

Problem with PHP Page

         

Gian04

1:41 am on Jun 20, 2007 (gmt 0)

10+ Year Member



I have a dynamic page (directory)

www.example.com/directory/mypage.php?page=1

If I click on the link to display page 2, page 3 and so on...

<a href=mypage.php?page=2>Page 2</a>

Most of the time it displays the page correctly, but sometimes it will just display a while background page with a "1" (w/o quotes) on the upper left part of the page.

I have checked my source repeatedly and I dont see any problem with my codes.

What seems to be the cause of this problem?

[edited by: Gian04 at 1:45 am (utc) on June 20, 2007]

eelixduppy

1:44 am on Jun 20, 2007 (gmt 0)



Are you getting any error messages in your logs? It seems as though it is a logical error, though. What would make it echo a '1' to the browser? Have you added error handling to your script?

Gian04

1:46 am on Jun 20, 2007 (gmt 0)

10+ Year Member



Yes I have error handling on my code, the problem is most of the time it displays correctly, theres no pattern when it display "1"

eelixduppy

1:49 am on Jun 20, 2007 (gmt 0)



I'm sure there's some hidden pattern ;)

There can be many different reasons why it isn't working. So you say you aren't getting any error messages?

Check your logic--make sure that everything is happening correctly. Add some echo statements to show that everything is working.

Gian04

1:53 am on Jun 20, 2007 (gmt 0)

10+ Year Member



when it display a white background with "1", ill just click the refresh button on my browser and it will load the page correctly. Am I correct that if the problem is in my code, no matter how many times I click the refresh it will load the same (white page with "1")?

eelixduppy

1:59 am on Jun 20, 2007 (gmt 0)



It could depend on how you coded it, however, if there is no possible way for the script to halt its execution and print something to the browser, then it could be a server error.

If you aren't getting any php errors, then it is not a syntax error. So it's either a logic error, or a problem with your server.

If you are confident that the logic is flawless and that there is no way a '1' could be the result of the script under certain circumstances, which may appear to be random, then it is a problem with the server; however, if its only happening with this script, than it is unlikely.

I cannot think of any other reason why the script would randomly stop working. Unfortunately without the code, you are going to have to do some investigation yourself.

We have a thread on troubleshooting [webmasterworld.com] that you may want to take a look at.

vincevincevince

2:02 am on Jun 20, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Before starting your debugging, check your error_log. If you don't understand the errors, ask here. If the script dies part way, it will most probably give out an error as a reason.

When you want to start debugging:

First, cut your source in half, match braces, and see which half the problem is in.

Second, cut your problematic source section in half, match braches, and see which half the problem is in.

Third, repeat second; until you have indentified the single line or command which causes the problem.

Finally, post that problematic line, which causes the problem even when all alone without any other PHP around it.

Gian04

2:22 am on Jun 20, 2007 (gmt 0)

10+ Year Member



OK thanks guys, Ill continue to search for the cause of this.

vincevincevince,
There is no error_log.
What makes me difficult to trace the problem is theres no pattern Im sure that its random, another problem is, if the problem is just a part of my code, at least the upper part of the page should load (header, logo, etc), in this case its a white page with "1"

eelixduppy

2:24 am on Jun 20, 2007 (gmt 0)



>> There is no error_log.

You can try turning up error_reporting [php.net] in the script. Add this to the top:


error_reporting(E_ALL);

vincevincevince

2:38 am on Jun 20, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Check your source for the functions die() and exit(). If they exist, they are sure candidates for your problem!

Gian04

3:56 am on Jun 20, 2007 (gmt 0)

10+ Year Member



Can I conclude now that the problem is the server?

I have tried to enter a non-existing page, most of the time it display my 404 page but in 1 occasion it display a white page with "1".

mattclayb

11:47 am on Jun 20, 2007 (gmt 0)

10+ Year Member



it's not the server.

it will be your code - time to get out your debugging magnifying glass and checking the pages that aren't displaying properly for errors.

those stray semicolons can be real slippery characters!

henry0

12:13 pm on Jun 20, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



if your code is not thousands lines long :)
post it

Gian04

12:28 pm on Jun 20, 2007 (gmt 0)

10+ Year Member



its really too long.

Another thing the page with white background with "i" also display when I tried to enter a non existing page, meaning that the problem is not on my page / code.

eelixduppy

1:03 pm on Jun 20, 2007 (gmt 0)



>> when I tried to enter a non existing page

Do you have any mod_rewrites going on? What do your error documents look like? The problem doesn't make much sense...

henry0

1:25 pm on Jun 20, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



following on eelix
If so then you have a logic/script flaw somewhere

forget about dynamic, database etc..
create a dir with 3 or 4 pages with hardcoded "hello world1, 2, etc..
use you pagination GET method and let us know how it works.

BTW
as is, if you modify in your browser the result, like changing p1 by p2 and press enter
does it deliver p2?

if entering a non existing page creates a problem
you mostly have a flaw somewhere in the pagination script.
Do you have something in your pagination that should prevent a non existing page to be called?

the pagination section should not be more than 50...+ lines
post it.

Gian04

2:11 pm on Jun 20, 2007 (gmt 0)

10+ Year Member



Sorry for the confusion.

When I say non existing page its a totally different PHP page (not the page number)

www.example.com/directory/mypage.php?page=1

<a href=mypage.php?page=2>Page 2</a>

When I say non existing page it is something like

http://www.example.com/nonexistingpage.php
and not
www.example.com/directory/mypage.php?page=nonexistingpage

eelixduppy

3:53 am on Jun 21, 2007 (gmt 0)



I'm not sure what the problem is, Gian04. You may want to contact your host if it continues to happen like that. Seems like a strange problem. If you find out get back to us, I'd like to know. Good luck

Gian04

7:41 am on Jun 21, 2007 (gmt 0)

10+ Year Member



I have not change anything on my pages (because Im confident that the problem is not my codes).

And im surfing my site for more than 7 hours since my previous post wasting my bandwidth hoping that Ill be able to figure out whats the real problem.

But until now I didnt encounter the white page with "1". I really dont know what it is. I did not contact my host because I dont know how to convince them that the problem is not my code, and Im afraid that they will not be able to see a white page with "1" because it shows in random.

By the way I have seen it both on IE and FF.

[edited by: Gian04 at 7:41 am (utc) on June 21, 2007]

Habtom

8:22 am on Jun 21, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



>> Im confident that the problem is not my codes

I can't eliminate it that boldly that infact the problem could have been caused by something you have overseen in your code. You might want to post your code here, and somebody in WW might sort it out for you.

Habtom

Gian04

10:07 am on Jun 21, 2007 (gmt 0)

10+ Year Member



But my point is, if it is my code, why does the same problem occurs randomly when I enter a non existing page (please refer to my previous post what I mean for a non existing page).