I've just started out coding in PHP but there is something stopping me from enjoying this experience. I have intermittent problems connecting to my website when I click any link. I'm currently using the following php as a test at http://mysite.com
:
<ul>
<li><a href="./">Home</a></li>
<li><a href="./index.php?nav=testone">Test 1</a></li>
<li><a href="./index.php?nav=testtwo">Test 2</a></li>
<li><a href="./index.php?nav=testthree">Test 3</a></li>
</ul>
<?php
if ($_GET["nav"] == "testone") {
echo "This is Test 1";
}
elseif ($_GET["nav"] == "testtwo") {
echo "This is Test 2";
}
elseif ($_GET["nav"] == "testthree") {
echo "This is Test 3";
}
else {
echo "Hello! Press a link.";
}
?>
The site loads fine at first but sometimes when I click a link (eg. link to mysite/index.php?nav=testtwo), it doesn't load and I get "The connection was reset" in my browser. I use site24x7.com to check that it's not just me who has this problem. Now if I use www.mysite.com/index.php?nav=testtwo, it loads fine, but even this fails eventually. It's a subdirectory domain but the root level domain loads consistently throughout all this. I've phoned my hosting provider who says the servers are fine and that I should check my php.ini but I have no idea what to look for. I did edit the following though:
from
max_execution_time = 300
max_input_time = 60
memory_limit = 18M
to
max_execution_time = 300000
max_input_time = 300000
memory_limit = 256M
But that didn't make any difference. I'd like to first of all diagnose the problem and I have no idea where to start. Please any input! Thanks!
Looks to me like the connection is being interrupted by a middle-party.
Are you accessing in a country with censorship (e.g. China), or in a location that employs censorship or packet inspection?
It could even be a poorly-configured corporate or school proxy.
EDIT: You say it still has problems via site24x7.com, so I am probably wrong. I'm not sure how that works -- does the URL include your site URL on the query string, or display the page content in the browser? If so, it still could be something odd triggering an obscure filter.
Alternatively it could be poor antivirus or firewall software on your local machine -- you can try disabling it. Can you provide the full URL so we can gauge the likelihood of this, and see what hosting company you are using?
This is not a PHP issue, this is a server issue or network connection issue. If you're really using http://mysite.com (especially their free service), then you really need to get a better host. Nothing in your script could cause the connection to reset.
Edit: If you just want to play with PHP, I'd suggest installing XAMPP on your local computer and then you don't have to worry about a remote server. When you're ready for a host then check out http:///www.webhostingtalk.com for a good host provider. Personally, when I needed simple & performant hosting, MediaLayer was really good.
Well, there's nothing wrong here with your code that should cause timeout problems. This really indicates a problem between your local connection and the server where the script is hosted at. Try running multiple traceroutes, that may give you some more details about the connection status itself.
Try hosting it elsewhere or running it local to ensure your config/script are not the problem, but it shouldn't be as long as you use default configurations for Apache/PHP, they are fine for most situations.
Furthermore, I hope you set your php.ini values for execution time back to default, these value are fine. The 300000 values are insane and should never be necessary. And it's not like anyone on the web is going to wait 300000 seconds for their page to show up anyway.
Could be a proxy between your browser and the server that's disconnecting you for several reasons: (1) IP address/range identified as a spam source, (2) IP address/range identified as a flooder (possible history of DoS attacks), (3) invalid HTTP referrer, (4) invalid HTTP user agent, (5) server just has too much traffic to handle, and the list goes on.
Change host.
Start with a localhost, for example by downloading xampp lite from apachefriends.org