0

Possible Duplicate:
mysql_fetch_array() expects parameter 1 to be resource, boolean given in select

$url = $this->getAppParam('sandbox') ? 'www.sandbox.paypal.com' : 'www.paypal.com';
// OCT 31,2011 : now paypal uses ssl:// in url and port 443
$fp = fsockopen ('ssl://'.$url , 443, $errno, $errstr, 30);
XiError::assert($fp);


// post data back to PayPal system to validate
$header  = "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Host: $url\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
fputs ($fp, $header . $req);

// read the response data now
$return = false;
while( ! feof($fp)){
    //XITODO : Add this to tmp log file
    $response = fgets ($fp, 1024); //echo $res;
    if (strcmp ($response, 'VERIFIED') == 0) {
    $return = true;
    }

    if (strcmp ($response, 'INVALID') == 0) {
        $return = false;
    }
}

XiError::Assert

static function assert($condition, $msg = '', $type = self::ERROR)
    {
        // assert only if in debug mode
        if($condition || !(JDEBUG)){
            return true;
        }

        //raise error
        if($type == self::ERROR){
            self::raiseError('XI-ERROR', $msg);
        }

        //raise warning
        if($type == self::WARNING){
            self::raiseWarning('XI-WARNING', $msg);
        }

        // enqueue message
        XiFactory::getApplication()->enqueueMessage('XI-WARNING : '.$msg);
    }

This is my code which I am using. It is generating warning PHP Warning: fgets() expects parameter 1 to be resource, boolean given in /var/www/**** 50 times in a second. This is causing 4 GB error log at my server. Any idea?

Community
  • 1
  • 1
Gaurav
  • 28,447
  • 8
  • 50
  • 80

1 Answers1

0

do not use socket! use CURL in php.Curl is best option in php when socket not working.

nikunj gandhi
  • 779
  • 5
  • 6