473,383 Members | 1,818 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Warning: fsockopen() [function.fsockopen]: unable to connect to

I am working on a script and i get this error

Warning: fsockopen() [function.fsockopen]: unable to connect to https://www.alertpay.com:443 (Unable to find the socket transport "https" - did you forget to enable it when you configured PHP?) in XXXXXXXXXXXXXX on line 84

I have contacted my host to make sure that ssl and all that is enabled he says it has been enabled and it still dont work

here is my server info
http://www.performancebux.com/info.php

If any one see what that problem is please let me know how to maybe fix it and maybe how to get it to work here is a copy of the php code that i am using to witch is causeing the problem

Expand|Select|Wrap|Line Numbers
  1. class CYsHttpClass
  2. {
  3.     protected $cookies, $postdata,$r_header,$r_content,$s_request;
  4.     final protected function addCookie($k, $v)
  5.     {
  6.         if(is_array($k))
  7.             for($i=0;$i<sizeof($k);$i++)
  8.                 $this->cookies[$k[$i]] = $v[$i];
  9.         else
  10.             $this->cookies[$k] = $v;
  11.     }
  12.     final protected function addPostData($k, $v)
  13.     {
  14.         if(is_array($k))
  15.             for($i=0;$i<sizeof($k);$i++)
  16.                 $this->postdata[$k[$i]] = $v[$i];
  17.         else
  18.             $this->postdata[$k] = $v;
  19.     }
  20.     final protected function httpConnect($url,$method='GET',$referer='',$useragent='PayChain')
  21.     {
  22.         $port = 80; //Set Default Port to 80
  23.         $method = strtoupper($method);
  24.  
  25.         list($protocol,$server,$script) = preg_split("/(http|https)?:\/\/([^\/]+)([^ ]*)/",$url,-1,PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
  26.  
  27.         if($protocol=="https")
  28.             $port = 443;
  29.  
  30.         if(strpos($server,":") != false)
  31.             list($server,$port) = preg_split("/([^:]+):(.+)/",$server,-1,PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
  32.  
  33.         $cookiestring = "";
  34.         if(is_array($this->cookies))
  35.             if(sizeof($this->cookies) > 0)
  36.                 foreach($this->cookies as $key=>$value)
  37.                 {
  38.                     if(strlen($cookiestring) != 0)
  39.                         $cookiestring .= '; ';
  40.                     $cookiestring .= urlencode($key) . '=' . urlencode($value);
  41.                 }
  42.  
  43.         $postdatastring = "";
  44.         if(is_array($this->postdata))
  45.         {
  46.             $postdatastring = "";
  47.             if(sizeof($this->postdata) > 0)
  48.                 foreach($this->postdata as $key=>$value)
  49.                 {
  50.                     if(strlen($postdatastring) != 0) $postdatastring .= '&';
  51.                     $postdatastring .= urlencode($key) . '=' . urlencode($value);
  52.                 }
  53.         }
  54.  
  55.         $this->postdata = array(); // reset postdata field after use
  56.  
  57.         $this->s_request="$method $script HTTP/1.1\r\n";
  58.         $this->s_request.="Host: $server\r\n";
  59.         $this->s_request.="Accept: */*\r\n";
  60.         if($cookiestring)
  61.             $this->s_request.="Cookie: $cookiestring\r\n";
  62.         if($referer)
  63.             $this->s_request.="Referer: $referer\r\n";
  64.         if($useragent)
  65.             $this->s_request.="User-Agent: $useragent\r\n";
  66.  
  67.         $this->s_request.="Connection: close\r\n";
  68.  
  69.         if($method == "POST")
  70.         {
  71.             $this->s_request.="Content-Type: application/x-www-form-urlencoded\r\n";
  72.             $this->s_request.="Content-Length: ".strlen($postdatastring)."\r\n";
  73.             $this->s_request.="\r\n$postdatastring\r\n";
  74.         }
  75.         else
  76.             $this->s_request.="\r\n";
  77.  
  78.         $sock = fsockopen(($protocol=="https"? "ssl://".$server : $server), $port, $errno, $errstr);
  79.         if($sock)
  80.             fwrite($sock, $this->s_request);
  81.         else
  82.         {
  83.             $this->r_header = "$errstr ($errno)";
  84.             return -1;
  85.         }
  86.  
  87.         $this->r_header = "";
  88.         while($str = trim(fgets($sock, 4096)))
  89.             $this->r_header .= "$str\n";
  90.  
  91.         if(preg_match_all("/Set-Cookie: (.*); path/", $this->r_header, $newcookie))
  92.             foreach($newcookie[1] as $c)
  93.             {
  94.                 list($k,$v) = explode("=", $c);
  95.                 $this->cookies[$k] = $v;
  96.             }    
  97.  
  98.         $this->r_content = "";
  99.         while(1)
  100.         {
  101.             $buf = fread($sock,8192);
  102.             if(strlen($buf) == 0) break;
  103.             $this->r_content .= $buf;
  104.         }
  105. //        echo("DEBUG:".$this->r_content);
  106.     }
  107. }
  108.  

please if any can give some advice please let me know
Nov 6 '08 #1
0 9979

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Andrew Montgomery | last post by:
If anybody has experienced the following SquirrelMail error: Warning: fsockopen(): unable to connect to xx.xx.xx.xx:143 in /home/virtual/siteX/fst/var/www/squirrelmail/functions/imap_general.php...
3
by: photoelectric | last post by:
When trying to run the below script on an apache/1.3.26 with mysql and php I get the following error message: Warning: mysql_connect() : Access denied for user: 'nobody@software-ece.rutgers.edu'...
5
by: Jesse | last post by:
I'm having issues attempting to create an ssl connection using fsockopen. my code contains the following line . fsockopen("ssl://siteaddr",993,$errno,$errmsg,20); error message reported:...
1
by: srinu | last post by:
Hello, We had one webserver based on a linux machine. The website is fully function and designed by a different person. Now we moved the machine from one IP to another one. I changed the...
6
by: murd | last post by:
Hi, I am trying to complete a post using fsockopen but I'm getting the following error: "Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP? I am...
1
by: Henry16 | last post by:
Never seen such a situation ! Do you have once faced this problem ? We use a fsockopen to retrieve a content from a URL . The content is dispalid corretly on a page on one of our servers. But...
4
by: MikeofPet | last post by:
I am trying to implement FTP in a PHP script but am unable to make the connection to the remote server. The connection step times out at the fsockopen function. I am not sure if it is relevant but...
0
by: susikto | last post by:
hi, I am getting this error when I am trying to connect the PSQL database. PHP Warning: pg_connect() : Unable to connect to PostgreSQL server: FATAL: user &quot;apache&quot; does not exist Can...
1
by: shlomisderot | last post by:
Hi all, I'm trying to connect to MSSQL by using PHP but I got the following error: Warning: mssql_connect() : Unable to connect to server: When I'm using ODBC to connect MSSQL with the same...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.