0

Getting this error after I hit this website 20 times IP blocking or any other thing I don't know why.

Warning: file_get_contents(http://www.azlyrics.com/a.html?time=1454075435): failed to open stream: HTTP request failed! in C:\xampp\htdocs\travel\simple_html_dom.php on line 77 Fatal error: Call to a member function find() on boolean in C:\xampp\htdocs\travel\searchplaylist.php on line 61

I've Code files If you want to I'll upload

both file codes in this link

https://drive.google.com/folderview?id=0BzMyD6UnaIfWZDZFWXN3akFwd2s&usp=sharing

1 Answers1

0

Just add @ infront of file_get_contents. (@file_get_contents).

This will not raise any errors if the request fails due to any reason.

My issue was that the server i was getting content from might be down sometimes and during those times i got an error. @ will not raise them.

But remember to use this only in cases where you understand why it might fail and you just want to handle those cases. Don't use it somewhere where you might have made mistakes and want to hide them.

Martin
  • 575
  • 6
  • 13
  • Furthermore, you might want to cache or save the results you get and during the times when the file_get_contents fails you can serve users the saved data. – Martin Jan 29 '16 at 14:10