Well I have been working on a backlinks checker, its pretty simple, checks the page to see if my url is included in their page. $htmlString=file_get_contents($line[0]); if (eregi('href=\"http://www.proxyslisted.com\" ', $htmlString)) { echo '<div class="backlinks"><a href="goto.php?id='.$counter.'" title="'.$line[0].'">'.$line[0].'</a></div>'; } PHP: So basically what I am curious about is how do I stop it from echoing out an error I have tried damn near everything and still I have got no where, checked the manual inside and out. I have just shut off error_checking so that it doesn't display anything but even still I want the script to run right not wrong. thanks, Brett
What error? You mean when it fails to open the site? http://www.php.net/operators.errorcontrol If that's not what you mean, be more specific...
yes sorry that is what I meant to say, and also is their anyways to speed this up, shouldn't i be able to close the file_get_contents everytime etc.? and yeah that worked perfectly never new about the @ sign like that thanks nico thanks, Brett
Not really. The speed depends on the other server. Your server makes an HTTP request to it, and it just takes its time. There's no need to close it. file_get_contents() will close the connection at the end of each request.
file_get_contents is pretty much a shortcut for fopen, fread, and fclose. So no, you don't need to close the file each time - file_get_contents already does that. As for the speed issue, yes and no. There's probably not much you can do to speed up the execution of the php script. Sending an http request (like opening a URL with file_get_contents) will take time because you have to wait for the other server to respond - sometimes several seconds. What you can do is use AJAX to make the request. This won't speed up the request, per se, but it will allow the page to load while you wait for the links to get checked - and this would be very advantageous if you were checking multiple pages at once. To do that, you first load the page. Once the page loads, it executes some Javascript that creates an AjaxRequest. The AjaxRequest calls the php script and gets the results from the remote page. You then insert the results of your AjaxRequest onto your page and update it in real time. - Walkere
you can always read line by line and stop when the desired result has been found. Just use: http://www.php.net/fgets
I understand the idea of AjaxRequests but have yet to figure out how to use them, how could this be done for this script? can your provide a example?
If you want to get a grasp on how to use AJAX, I'd suggest reading the first couple articles in the IBM Developer Works series. It gives you a great overview of how AJAX works and some code examples to get started. Once you've done that, find an AJAX framework, like prototype.js. There's some documentation on how to use prototype.js on their site. If you understand the concept, then prototype is very easy to implement. Good luck, - Walkere
i test my api site by load json file. I use file_get_contents but it seem to be slow. Anybody should me idea for this? Thanks