0

My source code is running 100% good when it is only on my localhost (XAMPP) but when I upload it my source code doesn't curl the sites, it cannot also provide any output. By the way I only upload my sample site to Hostinger.

image

Termininja
  • 6,620
  • 12
  • 48
  • 49
  • Please add details about your code, your server, and what exactly doesn't work... here, we can't guess... – Random Apr 13 '16 at 07:31
  • Possible duplicate of [Curl return false on hostinger server (curl enabled)](http://stackoverflow.com/questions/34929470/curl-return-false-on-hostinger-server-curl-enabled) – Ohgodwhy Apr 13 '16 at 07:31
  • 1
    firstly check if your server is enabled with curl http://php.net/manual/en/function.phpinfo.php, if that is not the case then please check for error http://php.net/manual/en/function.curl-strerror.php – JiteshNK Apr 13 '16 at 07:35
  • I checked already and it is stated that the curl is enabled – wrines wr ines Apr 13 '16 at 07:51
  • but still my source code doesn't work. – wrines wr ines Apr 13 '16 at 07:54
  • @wrines wr ines checked for error ?? still issue is there, then please paste the code here. Without that its difficult to find the issue. – JiteshNK Apr 13 '16 at 07:59
  • sorry @user2314870 I am just only a beginner. but I try to catch the error using this code echo error_reporting(E_ALL); and it provides an output of 32759 – wrines wr ines Apr 13 '16 at 08:16
  • Am I correct? or Just doing a mess?. if i am wrong please give me the sample code to get the error message so that I can provide you the error. – wrines wr ines Apr 13 '16 at 08:20
  • @wrines wr ines just post the code below in answer please check and let me know if your query is resolved or not – JiteshNK Apr 13 '16 at 09:28

3 Answers3

1

just checked your code, please add below lines at the end, you will come to know what is the error

if(curl_error($ch))
{
    echo 'error:' . curl_error($ch);
}
else{
    echo $content;  
}

replace $ch with $handle and also remove init_set function as of now

Output is

error:Could not resolve host: wwww.todayhumor.co.kr

Please check and confirm the Url

JiteshNK
  • 428
  • 2
  • 11
0

The issue is probably that curl is not enabled on your hosting server, you can see if that's the problem by using the phpinfo() function and you will be displayed everything that is enabled.

If it's not contact your hosting or change it.

Vasil Rashkov
  • 1,818
  • 15
  • 27
0

First, you have a missing } in for loop. But if it is just a typo, try to separate curl codes from your for loop.

You can move them to a function like this:

...
$link=...
curl_call($link);
Amir
  • 4,089
  • 4
  • 16
  • 28