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;
?> 7 13959
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
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
"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; ?>
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
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; ?>
>>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.
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 This discussion thread is closed Replies have been disabled for this discussion. Similar topics
1 post
views
Thread by reinhard |
last post: by
|
reply
views
Thread by Vineet Jain |
last post: by
|
reply
views
Thread by christian_stengel |
last post: by
|
reply
views
Thread by Benjamin Schollnick |
last post: by
|
4 posts
views
Thread by Justin Malloy |
last post: by
|
reply
views
Thread by pillars |
last post: by
|
reply
views
Thread by Chuck Anderson |
last post: by
|
reply
views
Thread by Vivek N |
last post: by
|
4 posts
views
Thread by keychain |
last post: by
| | | | | | | | | | |