To start: I am a C++ developer who is roped into making a PHP script (for paypal IPN).
I have been incredibly frustrated witht he lack of good working samples from paypal and elsewhere.
The latest problem is that I seem to not get any of the $HTTP_POST_VARS items that I think I should be getting.
Some searches online seem to indicate that this is either deprecated or configurable, etc.
I have no idea what version of PHP is used at my host.
It seems clear that either my testing applications do not post correctly or the script is not working.
so: 2 questions: - Does anyone have any links to working IPN scripts? - What gives with the $HTTP_POST_VARS nonsense?
EDIT
thanks all. I'll try these suggestions out and post up my success story soon I hope.
-
First thing to try is changing $HTTP_POST_VARS to $_POST. That's the new mechanism, and after some version or another $HTTP_POST_VARS stopped being a superglobal.
R. Bemrose : I believe it was when 5.0 was released, $HTTP_POST_VARS stopped being a global. -
You can check what version of PHP you are using by typing
phpinfo();into a PHP script block<?php ?>and see what it ouputs (or simply echoPHP_VERSION).$HTTP_POST_VARSis the old way of doing things. You can use$_POST['post-var']. To examine everything beint posted, useprint_r($_POST).Tim : thanks - I'll try thatHans : actually, i would recommend var_dump (or var_export) as alternatives to print_r... you get far better information (especially since $_POST is an array)alex : @Hans I'll try var_dump() neext time. -
As chaos already wrote, just use the
$_POSTarray instead of$HTTP_POST_VAR.
Two things i like to mention:
1.var_dump(somevar)function is very helpful in php. It displays structured information aboutsomevar. If you not sure how is some variable or array or what ever is structured, just use this function. So this callvar_dump($_POST);will display you all the current POST parameters.
2.phpinfo()function is helpful if you are interested which version and extensions is your host using. Just create a file with<?php phpinfo(); ?>in it and navigate with the browser to this file. Don't forget to remove it after this, because of the security leak.invenetix : I usually like doing.... echo "" . print_r($somevar) . "
"; It does the same thing, but prints it in an easier to read format. I think you can do var_dump() in the same spot at print_r(), but it's been a really long time since I've tried.alex : @Inventeix, should that be echo '' . print_r($somevar, true) . '
'; to get it to return and not simply echo? Maybe it doesn't matter.
0 comments:
Post a Comment