tags:

views:

43

answers:

1

My PHP code

    $urlArray = array('http://firsturl.com', 'http://secondurl.com');
    $nodeCount = count($urlArray);
    $chContainter = array();
    $mh = curl_multi_init();
    for($i = 0; $i < $nodeCount; $i++) {
        $chContainter[$i] = curl_init();
        curl_setopt($chContainter[$i], CURLOPT_URL, $urlArray[$i]);
        curl_setopt($chContainter[$i], CURLOPT_HEADER, 0);
        curl_setopt($chContainter[$i], CURLOPT_RETURNTRANSFER,1);
        curl_multi_add_handle($mh,$chContainter[$i]);
    } 

is generating the following warning

Warning: (null)(): 4 is not a valid cURL handle resource in Unknown on line 0

Warning: (null)(): 5 is not a valid cURL handle resource in Unknown on line 0

I did some debugging and found out the warning was generated when I try to add curl handle to the $mh.

Please help. Thanks.

A: 

I just resolved this problem on one of my own scripts. The issue was caused by URLs with unencoded spaces, for example: http://example.com/space here/. I resolved the issue by replacing any plain space with %20, like so: http://example.com/space%20here/

From other reading online, it seems like this error can occur for any reason that makes the URL inaccessible or otherwise malformed.

Ian