Http Posts

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

JellyFish wrote:But anyways, I don't understand what you mean by this: die( ............ 'The error is: '.$errstr);. I didn't get that.
Then you missed my post. Look up.
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

Post by JellyFish »

Okay, I read it up there. But can I set $errono or $errstr without passing the $port argument? How does that work?
miro_igov
Forum Contributor
Posts: 485
Joined: Fri Mar 31, 2006 5:06 am
Location: Bulgaria

Post by miro_igov »

Why you can't use cURL? not installed or your ISP blocks the outgoing requests? If 2nd you will not be able to run fsockopen too.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

Code: Select all

fsockopen($host, 80, $errno, $errstr);
echo "Error: $errstr (error code: $errno)";
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

Post by JellyFish »

Woaw. Wait a sec. I changed it to hearts:

Code: Select all

$socket = @fsockopen($url['host'], 80, $errno, $errstr) or die('Error: unable to open a socket connection with '.$url['host'].'\n $errno: $errstr');
And then my response:
HTTP/1.0 302 Moved Temporarily Location: https://www.linkpointcentral.com/lpc/servlet/lppay X-Cache: MISS from wc03.inet.mesa1.secureserver.net Connection: close
And I think that this is not an error but a response that function HttpRequest returns and that I echoed out.

Code: Select all

$transaction = HttpRequest("https://www.linkpointcentral.com/lpc/servlet/lppay", $myorder);

exit($transaction);
You see I used exit with the results of $transaction. I didn't state this before, and that's my bad. But now I think I actually was able to connect to the server, cuz look when I change [exit($transaction);] with [exit($transaction."CONNECTION WAS SUCCESSFUL!");] my response then becomes:
HTTP/1.0 302 Moved Temporarily Location: https://www.linkpointcentral.com/lpc/servlet/lppay X-Cache: MISS from wc02.inet.mesa1.secureserver.net Connection: close CONNECTION WAS SUCCESSFUL!

Yippee! Thanks for all the post guys, I'm so glad that this function works and ALL the help on this thread! Thank you guys SO, SO MUCH!

PS: I'll start another thread if I get any other troubles, considering this thread is getting a little to big. K?

POST-PS: Btw, what kind of http response is that anyway?
Last edited by JellyFish on Sat Aug 18, 2007 12:10 pm, edited 1 time in total.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

By the way, your die() uses single quotes.
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

Post by JellyFish »

superdezign wrote:By the way, your die() uses single quotes.
What's wrong with that?
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

JellyFish wrote:
superdezign wrote:By the way, your die() uses single quotes.
What's wrong with that?
... "\n", "$errno", "$errstr".
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

Post by JellyFish »

superdezign wrote:
JellyFish wrote:
superdezign wrote:By the way, your die() uses single quotes.
What's wrong with that?
... "\n", "$errno", "$errstr".
I really don't understand what you're trying to say but I'll change them.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

Really? Oh, then this is definitely a detail that you'll need to know.

Single quotation marks take variables as literal strings, not regular variables. Also, it doesn't render special characters.
Double quotation marks allow you to place variables inline and render special characters, such as the newline.
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

Post by JellyFish »

superdezign wrote:Really? Oh, then this is definitely a detail that you'll need to know.

Single quotation marks take variables as literal strings, not regular variables. Also, it doesn't render special characters.
Double quotation marks allow you to place variables inline and render special characters, such as the newline.
Oooooooooooooooooooooooooooooooooooooooooooooooooooooooooh yeah! I almost forgot. So by me using single quotes I shouldn't expect $errno and $errstr to out put as the values of these variables.

Thanks.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

JellyFish wrote:I already stated that I can not use the port on my server to connect to a remote server, thus I can not use cURL methods. My only option is to make a post request.
That doesn't make much sense. curl sends a post request if you set CURLOPT_POST
Post Reply