homepage Welcome to WebmasterWorld Guest from 54.196.62.23
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
PHP Opera page load problem.
Simone100

5+ Year Member



 
Msg#: 3364043 posted 4:48 am on Jun 11, 2007 (gmt 0)

Hello, need help with opera regarding php and any page load.

I have opera 9.0. and when I open a web page with opera with any php applications that are supposed to change on page load, Opera doesn't seem to be working right. When the page is viewed through the opera browser it doesn't refresh the first time when the page opens. It only refreshes and changes an item when you click opera's refresh button. This is just one example of what I mean.

Quote:
<?php $this = rand(1,15);
$includeit = "on" . $this . ".txt";
include ($includeit);?>

Codes like this are supposed to show a different item
on page load. But when opera first opens to the page address,
it is still showing the last random item.
I really don't believe your supposed to click opera's refresh button when you first open a web page. I relieve believe its supposed to show an different item each time. Can someone tell me what is happening with only Opera or if I am doing something wrong? Thank you very much.

 

CDNQuilter

5+ Year Member



 
Msg#: 3364043 posted 5:32 am on Jun 11, 2007 (gmt 0)

My first guess would be that when you last viewed the page in Opera, the page was cached and so when you re-load the page(as opposed to refresh) it gets the page from cache instead.
Opera's cache settings are under tools/preferences/advanced/history
Play around with them to see if setting check documents to always fixes the problem.
edited to fix spelling

[edited by: CDNQuilter at 5:34 am (utc) on June 11, 2007]

Simone100

5+ Year Member



 
Msg#: 3364043 posted 5:41 am on Jun 11, 2007 (gmt 0)

Thanks that helps a lot. It doesn't seem to be a cache issue? I edited the cache preferences and also looked to see if there was anything in advanced, nothing helped this.

[edited by: Simone100 at 6:01 am (utc) on June 11, 2007]

Simone100

5+ Year Member



 
Msg#: 3364043 posted 7:05 am on Jun 11, 2007 (gmt 0)

Maybe I should see if I can reset Opera back to a default in case I accidentally messed something up. Anyone now if opera has a reset to default? Thanks.

Simone100

5+ Year Member



 
Msg#: 3364043 posted 8:16 am on Jun 11, 2007 (gmt 0)

I downloaded a new version 9.21 of Opera at opera.com/download for English version number 2 and I'm having the same problem. After deleting the first one and restarting the computer. So doesn't look like its me, look likes its Opera. Hoping someone will see this that knows what is wrong.

CDNQuilter

5+ Year Member



 
Msg#: 3364043 posted 2:45 pm on Jun 11, 2007 (gmt 0)

The browser doesn't see your php.

It only sees the html generated at the server by your php.

So it has to be either a cache issue or something somewhere else in your code.

To set the browser so that it always loads a fresh page, do not use the tools/advanced
use tools/preferences/advanced/history
Beside the Disk cache drop down box, click on Empty Cache
and in the drop down box beside
check documents
select 'always'

How many different pages are you choosing from? A random selection means that there is a definite chance that sometimes the same page as the one you are viewing will be chosen. If you have only a few pages to select from, then this will happen fairly frequently.

eelixduppy

WebmasterWorld Senior Member eelixduppy us a WebmasterWorld Top Contributor of All Time 5+ Year Member



 
Msg#: 3364043 posted 2:48 pm on Jun 11, 2007 (gmt 0)

You can always force the browser to grab the new content. Try adding this to the top of your php script:

#taken from manual
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");

Simone100

5+ Year Member



 
Msg#: 3364043 posted 10:54 pm on Jun 11, 2007 (gmt 0)

I'll try it eelix. That would be the best way because I'm worried about other people that use opera's browsers not reading the code too.

Its not a random issue picking the same item, this same thing happens on other codes that aren't picked randomly.

[edited by: Simone100 at 10:55 pm (utc) on June 11, 2007]

Simone100

5+ Year Member



 
Msg#: 3364043 posted 11:15 pm on Jun 11, 2007 (gmt 0)

What normal header am I supposed to remove? It says header has already been sent.

eelixduppy

WebmasterWorld Senior Member eelixduppy us a WebmasterWorld Top Contributor of All Time 5+ Year Member



 
Msg#: 3364043 posted 11:27 pm on Jun 11, 2007 (gmt 0)

>>It says header has already been sent.

That means exactly what it says, you have had headers sent out before you called this function. You must have the code I gave you at the very top of the script before any output is sent to the browser (this includes text, whitespace, etc...)

Simone100

5+ Year Member



 
Msg#: 3364043 posted 11:53 pm on Jun 11, 2007 (gmt 0)

This is how I have it, no white space.
<?php
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
$getfile = rand(1,8);
$includefile = "file" . $getfile . ".txt";
include ($includefile);
?>

Is it talking about conflicting with a html header at the top of the page?

This is how the top of the page looks.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type" />
<title>starter</title>
<style type="text/css">
.main { border: 5px solid rgb(0, 0, 0);
margin: auto;
width: 600px;
}
.body { margin: auto;
display: block;
width: 100%;
height: 100px;
}
</style>
</head>
<body>

Simone100

5+ Year Member



 
Msg#: 3364043 posted 8:12 am on Jun 14, 2007 (gmt 0)

Anyone know why my page is saying header has already been sent?
Thanks a lot.

<?php
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
$this = rand(1,8);
$includefile = "file" . $this . ".txt";
include ($includefile);
?>

omoutop

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 3364043 posted 8:40 am on Jun 14, 2007 (gmt 0)

it is just eelixduppy suggested.
White spces, text or something is sent to the borwser.

make sure that no include file outputs anything before headers.
check whitespaces in your scrip[t, in includes, in everything
check error reporting (you'll never know)

if you still see this message, check again.

Try testing this page in IE and Opera. If it works on one, then its cashe problem, else .... check again.

Sorry, but there isnt much you can do in this case (at least none that i am familiar with).

If anyone has any suggestion, please let us know.

Simone100

5+ Year Member



 
Msg#: 3364043 posted 12:13 am on Jun 16, 2007 (gmt 0)

I put this in a page all by itself and not getting the double header message anymore. But this still does not change an item in opera without using opera's refresh button. All other browsers are fine.
<?php
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
$this = rand(1,8);
$includefile = "file" . $this . ".txt";
include ($includefile);
?>

So this header didn't help.
I really don't get it, doesn't opera honor php? By doing a page refresh when it first opens a page or comes back to a page from another page? Seeing if I can find an opera forum in these forums.

eelixduppy

WebmasterWorld Senior Member eelixduppy us a WebmasterWorld Top Contributor of All Time 5+ Year Member



 
Msg#: 3364043 posted 1:30 pm on Jun 16, 2007 (gmt 0)

>> I really don't get it, doesn't opera honor php?

The browser doesn't get the php code - only what the php outputs.

>> Seeing if I can find an opera forum in these forums.

[webmasterworld.com...]

It definitely is a cache problem, however, I cannot figure out why.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved