php_joe Posted August 29, 2009 Share Posted August 29, 2009 Hi, I'm having problems getting information from a website. Whatever I do times out. Even a simple code like this: <?php echo file_get_contents("http://shop.darkswords.ru"); ?> Here is the address: http://shop.darkswords.ru I can't figure out what's wrong. Thanks! Joe Quote Link to comment https://forums.phpfreaks.com/topic/172350-problem-always-timing-out/ Share on other sites More sharing options...
trq Posted August 29, 2009 Share Posted August 29, 2009 Have you got error reporting and display errors on? What error (if any) are you getting? Quote Link to comment https://forums.phpfreaks.com/topic/172350-problem-always-timing-out/#findComment-908707 Share on other sites More sharing options...
oni-kun Posted August 29, 2009 Share Posted August 29, 2009 I just tested grabbing that site and it works fine, it may be a problem with your server being able to reach that site.. I'd recommend using CURL for this as it requests the page with headers instead of physically gets the page contents. Quote Link to comment https://forums.phpfreaks.com/topic/172350-problem-always-timing-out/#findComment-908719 Share on other sites More sharing options...
trq Posted August 29, 2009 Share Posted August 29, 2009 file_get_contents uses http the same as curl does. Maybe however you do not have url_wrappers enabled. This is why you need to turn on error reporting and try again. Quote Link to comment https://forums.phpfreaks.com/topic/172350-problem-always-timing-out/#findComment-908726 Share on other sites More sharing options...
php_joe Posted August 29, 2009 Author Share Posted August 29, 2009 I was trying CURL originally, because I wanted to log in and submit an action. It timed out, so I tried file_get_contents() as a test, and it timed out too. file_get_contents() works fine for every other site that I've tried it on. The error code I'm getting says this: Warning: file_get_contents(http://shop.darkswords.ru) [function.file-get-contents]: failed to open stream: Connection timed out in /hsphere/local/home/mysite.com/testfile.php on line 2 I'm wondering if it has something to do with the encoding. The site was written and hosted in Russia, and the comments are in Russian. Could there be some kind of (human) language-based incompatibility? Joe Quote Link to comment https://forums.phpfreaks.com/topic/172350-problem-always-timing-out/#findComment-908752 Share on other sites More sharing options...
oni-kun Posted August 29, 2009 Share Posted August 29, 2009 I'm not sure the encoding would mess with it. If you're really wanting to fix that, if that is the problem.. try.. $html = utf8_encode(file_get_contents('www.example.com')); And that should fix the encodings as it's coming along.. But how about you jack the max execution time via php.ini or .htaccess? You can finally debug how long it is taking, or if it is NOT connecting at all to that server. CURL would be a better option as you can define ports and change the connection timeout variable, you can tinker to see how long it really takes.. Quote Link to comment https://forums.phpfreaks.com/topic/172350-problem-always-timing-out/#findComment-908807 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.