Title should be 'PHP not working in Opera'

Hey guys, I have some code which validates fine with the w3c validator, but still refuses to work in opera...

Wondered if anyone could maybe tell wny this code works in every browser but opera? I'm stumped.

<?php
if($_GET['act'] == "generate_quotes") {

	$con = mysql_connect("*", "*", "*");
	if (!$con)
  	{
  		die('Could not connect: ' . mysql_error());
  	}
	mysql_select_db("quote", $con);
				 
	$result = mysql_query( ' SELECT * FROM `quote`  ORDER BY RAND() LIMIT 0,1 ' );

	while($row = mysql_fetch_array($result))
  	{
 		echo '' . $row['q_quote'] . '';
 	}
	mysql_close($con);

} else { 

	echo "<img src='img/vpbgt.png' alt='hello'>";
	
}
?>

And the link that's meant to change the text:

<p id="Generate">  
<a href="index.php?act=generate_quotes" class="main_control">Generate</a></p>

At first I thought it may have been a cache problem...but apparently not. Anyone got any suggestions?

Recommended Answers

All 13 Replies

what if you do:

<p id="Generate">  
<a href="index.php?act=generate_quotes&cb=<?php echo time();?>" class="main_control">Generate</a></p>

what if you do:

<p id="Generate">  
<a href="index.php?act=generate_quotes&cb=<?php echo time();?>" class="main_control">Generate</a></p>

Oh wow thanks a lot for that, worked perfectly. Just out of curiosity, do you mind me asking what :

&cb=<?php echo time();

is doing differently? I've never come across that before, I'd just like to know for possible future problems. But thanks alot. Can't believe it was that simple.

From the best I can tell &cb is a way of telling the server to pick a new file. So it was a cache problem all along. Maybe a setting in Apache or PHP since I have never got the problem.

The time changes every milisecond and when the parameters change the server detects this change and so picks a new file and will not go form cache.

Thanks for all the info guys, but just a slight problem with the code. It seems to be freezing at odd intervals...anyone else ever had this problem?

it does what it's meant to do...but freezes every so often...

//edit - Doesn't seem to be occurring anymore.

But I appreciate all the help and good explanations.

Greatly appreciated.

Are you using Ubuntu 10.04 for your server? I have noticed a slight sleeping problem with it that has got me searching google high and low.

But at the same time could be server config or bad PHP coding, best thing to do is debug it with xdebug and find out where it slows down, might be a external webservice call or something (cache refresh on SOAP objects) etc.

Are you using Ubuntu 10.04 for your server? I have noticed a slight sleeping problem with it that has got me searching google high and low.

But at the same time could be server config or bad PHP coding, best thing to do is debug it with xdebug and find out where it slows down, might be a external webservice call or something (cache refresh on SOAP objects) etc.

No no using Apache at the moment. For some odd reason it does it when you click too frequently. Doesn't seem to happen when you click it as a slower speed. Can't even begin to imagine why this would be happening. But i figured I'd wait until my sites hoasted and see if the problem persists. Running my site locally at the moment.

But thanks for the info.

For some odd reason it does it when you click to frequently. Doesn't seem to happen when you click it as a slower speed. Can't even begin to imagine why this would be happening.

Parser speed or Browser speed...tried in Google Chrome or Firefox? If it is fine in those browsers then it is the browser otherwise it is sever memory/PHP parser speed/PHP code speed. I think this since if you press refresh on a heavy PHP page constantly the connections and parsing of pages grows on the server having a physical effect. The way connections are taken away after you load a page is through timeout...much like setting your own session handler on PHP you set a GC (Garbage collection) to delete all sessions after a certain period that have not been active.

Yea I meant what OS are you using because I use Apache on Ubuntu 10.04 and I get a strange sleeping problem if I leave the connection inactive for 10 mins...but you can't be using Ubuntu by the sounds of it...as a matter of interest what OS are you using Apache on?

Parser speed or Browser speed...tried in Google Chrome or Firefox? If it is fine in those browsers then it is the browser otherwise it is sever memory/PHP parser speed/PHP code speed. I think this since if you press refresh on a heavy PHP page constantly the connections and parsing of pages grows on the server having a physical effect. The way connections are taken away after you load a page is through timeout...much like setting your own session handler on PHP you set a GC (Garbage collection) to delete all sessions after a certain period that have not been active.

Yea I meant what OS are you using because I use Apache on Ubuntu 10.04 and I get a strange sleeping problem if I leave the connection inactive for 10 mins...but you can't be using Ubuntu by the sounds of it...as a matter of interest what OS are you using Apache on?

Aaa I see. But just quickly tested it in safari and FF and worked fine. So still a bit of a opera issue. Sorry I've no idea why I just left it at that, I'm using Vista ;)

Yea another Opera error, I had a link describing from the logo how Opera operates (very funny) but it's since been lost and a search on Google turned up nothing. Heh I missed out Vista so I'm safe from its terrible nature.

But anyway happy coding :)

P.S. Just a little tip here, be careful of what file system functions you use under windows PHP since the hosting provider will be using Ubuntu or Red Hat or just Linux in general and some functions do not work the same under Windows as they do Linux...just a precautionary note

Yea another Opera error, I had a link describing from the logo how Opera operates (very funny) but it's since been lost and a search on Google turned up nothing. Heh I missed out Vista so I'm safe from its terrible nature.

But anyway happy coding :)

P.S. Just a little tip here, be careful of what file system functions you use under windows PHP since the hosting provider will be using Ubuntu or Red Hat or just Linux in general and some functions do not work the same under Windows as they do Linux...just a precautionary note

You know what I didn't think about that at all. Very good point. I don't really have anyway to test on Linux, so I guess I'll just hope for the best...then scream when it all goes wrong :icon_eek:

But thanks for the heads up, appreciate it. +1's all round! :icon_razz:

Oh wow thanks a lot for that, worked perfectly. Just out of curiosity, do you mind me asking what : ... is doing differently?

"cb" is my abbreviation for "cache buster". The behavior you described is something I have seen before mostly in IE. So a quick "fix" is to change the URL every time. In this case the querystring will change on every request since time() will be different every time. That way the browser will "force" itself to request a new copy of the page on every request.

From the best I can tell &cb is a way of telling the server to pick a new file. So it was a cache problem all along. Maybe a setting in Apache or PHP since I have never got the problem.

This is not a server issue. It's a browser issue. The server simply responds to the requests made by the browser. The browser is the one that decides whether to fetch a new page or to use a cached copy of the page in question.

The time changes every milisecond and when the parameters change the server detects this change and so picks a new file and will not go form cache.

Again, the server has nothing to do with the problem. The server does NOT "detect" a change. It simply responds to the requests made by browser. Ultimately the browser "thinks" that:
http://yoursite.com/file.php?x=3&cb=3434346565

is different from:
http://yoursite.com/file.php?x=3&cb=5434346565

and issues a request to the server.

Did I say server? oops sorry :( I should of said browser

Must of been thinking about something else at the time

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.