473,378 Members | 1,380 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,378 software developers and data experts.

Warning: fgets(): SSL: fatal protocol error

Okay, I am working on a credit card validation script, I have it
working perfectly (saving the return information from the server to a
variable and echoing it for now) other than this weird error on the
fgets() line. I can't seem to figure out the problem, the code is
below, any help is appreciated!

<?php
$host = "secure.authorize.net";
$port = 443;
$path = "/gateway/transact.dll";
$formdata = array ("x_form_post_data_here" => "value");
foreach($formdata AS $key => $val){
$poststring .= urlencode($key) . "=" . urlencode($val) . "&";
}
$poststring = substr($poststring, 0, -1);
$fp = fsockopen("ssl://".$host, $port, $errno, $errstr, $timeout =
30);
if(!$fp){
echo "$errstr ($errno)\n";
}else{
fputs($fp, "POST $path HTTP/1.0\r\n");
fputs($fp, "Host: $host\r\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
fputs($fp, "Content-length: ".strlen($poststring)."\r\n");
fputs($fp, "Connection: close\r\n\r\n");
fputs($fp, $poststring . "\r\n\r\n");
while(!feof($fp)) {
$out_put_string .= fgets($fp, 4096); //<== HERE IS THE ERROR LINE #
}
fclose($fp);
}
echo $out_put_string;
?>
Jul 16 '05 #1
7 14045
Adam Bergman wrote:
Okay, I am working on a credit card validation script, I have it
working perfectly (saving the return information from the server to a
variable and echoing it for now) other than this weird error on the
You've forgotten to mention what the error is :)
fgets() line. I can't seem to figure out the problem, the code is
below, any help is appreciated!

<?php
$host = "secure.authorize.net";
$port = 443;
$path = "/gateway/transact.dll";
$formdata = array ("x_form_post_data_here" => "value");
foreach($formdata AS $key => $val){
$poststring .= urlencode($key) . "=" . urlencode($val) . "&";
}
$poststring = substr($poststring, 0, -1);
$fp = fsockopen("ssl://".$host, $port, $errno, $errstr, $timeout =
30);
if(!$fp){
echo "$errstr ($errno)\n";
}else{
fputs($fp, "POST $path HTTP/1.0\r\n");
fputs($fp, "Host: $host\r\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
fputs($fp, "Content-length: ".strlen($poststring)."\r\n");
fputs($fp, "Connection: close\r\n\r\n");
fputs($fp, $poststring . "\r\n\r\n");
while(!feof($fp)) {
$out_put_string .= fgets($fp, 4096); //<== HERE IS THE ERROR LINE #
}
fclose($fp);
}
echo $out_put_string;
?>


--
MeerKat

Jul 16 '05 #2
MeerKat wrote:
Adam Bergman wrote:
Okay, I am working on a credit card validation script, I have it
working perfectly (saving the return information from the server to a
variable and echoing it for now) other than this weird error on the

You've forgotten to mention what the error is :)


OK, now I see it hidden in the subject line... What version of PHP do
you have? SSL is only supported on PHP 4.3 and above.

(apologies for the messed up formatting of this message... stupid
computers...)
fgets() line. I can't seem to figure out the problem, the code is
below, any help is appreciated!

<?php
$host = "secure.authorize.net"; $port = 443; $path =
"/gateway/transact.dll"; $formdata = array ("x_form_post_data_here" =>
"value");
foreach($formdata AS $key => $val){ $poststring .=
urlencode($key) . "=" . urlencode($val) . "&"; } $poststring =
substr($poststring, 0, -1); $fp = fsockopen("ssl://".$host, $port,
$errno, $errstr, $timeout =
30);
if(!$fp){ echo "$errstr ($errno)\n"; }else{ fputs($fp, "POST $path
HTTP/1.0\r\n"); fputs($fp, "Host: $host\r\n"); fputs($fp,
"Content-type: application/x-www-form-urlencoded\r\n"); fputs($fp,
"Content-length: ".strlen($poststring)."\r\n"); fputs($fp,
"Connection: close\r\n\r\n"); fputs($fp, $poststring . "\r\n\r\n");
while(!feof($fp)) { $out_put_string .= fgets($fp, 4096); //<==
HERE IS THE ERROR LINE #
} fclose($fp); } echo $out_put_string;
?>



--
MeerKat

Jul 16 '05 #3
sam
"Adam Bergman" <ad**@a2ztech.net> wrote in message
news:a7*************************@posting.google.co m...
Okay, I am working on a credit card validation script, I have it
working perfectly (saving the return information from the server to a
variable and echoing it for now) other than this weird error on the
fgets() line. I can't seem to figure out the problem, the code is
below, any help is appreciated!

<?php
$host = "secure.authorize.net";
$port = 443;
$path = "/gateway/transact.dll";
$formdata = array ("x_form_post_data_here" => "value");
foreach($formdata AS $key => $val){
$poststring .= urlencode($key) . "=" . urlencode($val) . "&";
}
$poststring = substr($poststring, 0, -1);
$fp = fsockopen("ssl://".$host, $port, $errno, $errstr, $timeout =
30);
Here, you get $fp = null
I don't know a protocol named SSL (Secure Socket Layer)?????
You mean HTTPS. So, change 'ssl' with 'https'.
if(!$fp){
echo "$errstr ($errno)\n";
}else{
fputs($fp, "POST $path HTTP/1.0\r\n");
fputs($fp, "Host: $host\r\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
fputs($fp, "Content-length: ".strlen($poststring)."\r\n");
fputs($fp, "Connection: close\r\n\r\n");
fputs($fp, $poststring . "\r\n\r\n");
while(!feof($fp)) {
$out_put_string .= fgets($fp, 4096); //<== HERE IS THE ERROR LINE #
}
fclose($fp);
}
echo $out_put_string;
?>

Jul 16 '05 #4
On Mon, 15 Sep 2003 21:06:14 -0500, Adam Bergman created an award-winning
crop circle <a7*************************@posting.google.com> , which, when
translated into English, means this:
Okay, I am working on a credit card validation script, I have it
working perfectly (saving the return information from the server to a
variable and echoing it for now) other than this weird error on the
fgets() line.
[...]
fputs($fp, "POST $path HTTP/1.0\r\n");
fputs($fp, "Host: $host\r\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
fputs($fp, "Content-length: ".strlen($poststring)."\r\n");
fputs($fp, "Connection: close\r\n\r\n");
fputs($fp, $poststring . "\r\n\r\n");
while(!feof($fp)) {
$out_put_string .= fgets($fp, 4096); //<== HERE IS THE ERROR LINE #
[...]


My experience has been that, when using fsockopen
to do an HTTP POST, \r\n does not work as a line
terminator. I've been forced to use just \n.

YMMV

The standard says that lines end with \r\n, but somehow
with PHP and fsockopen() that does not work. Here is my
post where I show what I did:

<pa********************************@REMOVE.MEearth link.INVALID>

HTH

Jul 16 '05 #5
The error syntax is in the subject as well as the line number
commented in the code. What more do you want?

MeerKat <li****************@blueyonder.co.uk> wrote in message news:<Lm*****************@news-binary.blueyonder.co.uk>...
Adam Bergman wrote:
Okay, I am working on a credit card validation script, I have it
working perfectly (saving the return information from the server to a
variable and echoing it for now) other than this weird error on the


You've forgotten to mention what the error is :)
fgets() line. I can't seem to figure out the problem, the code is
below, any help is appreciated!

<?php
$host = "secure.authorize.net";
$port = 443;
$path = "/gateway/transact.dll";
$formdata = array ("x_form_post_data_here" => "value");
foreach($formdata AS $key => $val){
$poststring .= urlencode($key) . "=" . urlencode($val) . "&";
}
$poststring = substr($poststring, 0, -1);
$fp = fsockopen("ssl://".$host, $port, $errno, $errstr, $timeout =
30);
if(!$fp){
echo "$errstr ($errno)\n";
}else{
fputs($fp, "POST $path HTTP/1.0\r\n");
fputs($fp, "Host: $host\r\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
fputs($fp, "Content-length: ".strlen($poststring)."\r\n");
fputs($fp, "Connection: close\r\n\r\n");
fputs($fp, $poststring . "\r\n\r\n");
while(!feof($fp)) {
$out_put_string .= fgets($fp, 4096); //<== HERE IS THE ERROR LINE #
}

fclose($fp);
}
echo $out_put_string;
?>

Jul 16 '05 #6
>>RE:SAM
Here, you get $fp = null
I don't know a protocol named SSL (Secure Socket Layer)?????
You mean HTTPS. So, change 'ssl' with 'https'.
Actually, HTTPS is an unknown protocol you MUST use SSL (see the
fsockopen() function reference on PHP.net). If I use HTTPS as the
protocol I get all sorts of errors.
RE:GARY
My experience has been that, when using fsockopen
to do an HTTP POST, \r\n does not work as a line
terminator. I've been forced to use just \n.


I tried removing all the \r's from my headers however it did not
change the error message I am getting. I did however, set the text
size of the error to 1pt (with style), made it the background color,
and used the visibility style tag to hide the layer that the error
mes. is on so at least people can't see it.

I AM receiving the correct response from the server, I just get that
weird error.
Jul 16 '05 #7
Adam Bergman wrote:
The error syntax is in the subject as well as the line number
commented in the code. What more do you want?
Sorry. Forgive me. Please.

Are you using a PHP version below 4.3?
MeerKat <li****************@blueyonder.co.uk> wrote in message news:<Lm*****************@news-binary.blueyonder.co.uk>...
Adam Bergman wrote:

Okay, I am working on a credit card validation script, I have it
working perfectly (saving the return information from the server to a
variable and echoing it for now) other than this weird error on the


You've forgotten to mention what the error is :)

fgets() line. I can't seem to figure out the problem, the code is
below, any help is appreciated!

<?php
$host = "secure.authorize.net";
$port = 443;
$path = "/gateway/transact.dll";
$formdata = array ("x_form_post_data_here" => "value");
foreach($formdata AS $key => $val){
$poststring .= urlencode($key) . "=" . urlencode($val) . "&";
}
$poststring = substr($poststring, 0, -1);
$fp = fsockopen("ssl://".$host, $port, $errno, $errstr, $timeout =
30);
if(!$fp){
echo "$errstr ($errno)\n";
}else{
fputs($fp, "POST $path HTTP/1.0\r\n");
fputs($fp, "Host: $host\r\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
fputs($fp, "Content-length: ".strlen($poststring)."\r\n");
fputs($fp, "Connection: close\r\n\r\n");
fputs($fp, $poststring . "\r\n\r\n");
while(!feof($fp)) {
$out_put_string .= fgets($fp, 4096); //<== HERE IS THE ERROR LINE #
}


fclose($fp);
}
echo $out_put_string;
?>


--
MeerKat

Jul 16 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: reinhard | last post by:
Our project was developed with Python 2.0 and includes some Tk 8.3 extension widgets as well as python extensions using the CXX interface. After moving to Python 2.3 and TclTk 8.4 our program...
0
by: Vineet Jain | last post by:
I'm running a process which uses python numeric arrays extensively and also does some calculations in c. All objects are created in python or through the Numeric library and then passed to the c...
0
by: christian_stengel | last post by:
Hi *, I have just started to learn python and I am having a problem with an python client connecting to a perl server using ssl (I tried this with pyOpenSSL and with the build in SSL Module). ...
0
by: Benjamin Schollnick | last post by:
Folks, With Windows XP, and Python v2.41 I am running into a problem.... The following code gives me an unknown protocol error.... And I am not sure how to resolve it... I have a API...
4
by: Justin Malloy | last post by:
I am using the System.Net.Webclient to try and download an XML file from a website but am receiving a HTTP protocol error when running the DownloadFile() sub routine. I did a HTTP trace using...
0
by: pillars | last post by:
I have been developing an application in Windows CE.Net using the .Net Compact Framework and C#. Data is saved to a local Sql Server CE database and then transferred wirelessly to a central server....
0
by: Chuck Anderson | last post by:
I have a set of Php scripts that run on my home PC (Windows XP- Apache 2 - Php 4.4.1) that reads my web sites' daily Apache access log file (a gzipped file) on the remote server...
0
by: Vivek N | last post by:
Hi, I'm getting this oracle error intemittently Error Description: ORA-03106: fatal two-task communication protocol error. I'm not sure what is causing this. My application is a ASP.Net 2.0...
4
by: keychain | last post by:
I'm experience the infamous "SSL: Fatal Protocol Error" bug with Apache 2.x According the fopen() documentation: "If you are using fsockopen() to create an ssl:// socket, you are responsible...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.