Hi guys, I have spent whole day in debugging in it, but can't get any solution... PLz anyone help me. I am trying to fetch data from a site by using curl. My PHp version is 4.3.9 Here is the code i have used, function ipaddress($ip) { $url = 'http://www.example.com?x=' . $ip; $curl = curl_init ($url) or die ('curl_init() failed'); curl_setopt ($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt ($curl, CURLOPT_TIMEOUT, 5); curl_setopt ($curl, CURLOPT_URL, $url); $data = curl_exec ($curl); curl_close ($curl); } I call this function for about 60 times in a loop with different ip address at a single page load. On doing this often the server get crashed and my site is not loading. It get loading only after i restarted the server. I searched in some forums, they all said about the execution timeout and the connection timeout... Anyone who had be familiar with this can help me or suggest me an alternative way to do this... Thank you...
You are on PHP 4.3.9 ??!!? You can find free hosts with 5.2+ or pay $6 for a small linux vps (if you know linux) and install anything you want.
I doubt the version of PHP matters here. The issue is undoubtedly that the script is taking too long to run and the host server is timing out. Unless you have a dedicated server or virtual dedicated server where you can control the timeout settings, there's really no direct workaround for this. Shared hosts have to limit script execution times or they risk slowing down all of the sites that run on that server. Setting up a data cache might work for you. That is, you could periodically run a task that updates a database/file that includes the information that your script currently generates. By limiting the task to updating a limited number of ip addresses on each run, you should be able to keep the information relatively fresh and avoid re-fetching the same data every time the destination page is requested by users.
maybe you should run the top command and then try running the script to see what is causing and using the memory at that particular time