I'm currently testing a script on my host. This script is to accept PayPal IPN data, do a couple of things (ie. data verification), send necessary data to a specific email address, and more.
I'm using a test tool on the PayPal site to post test data to my script. My script doesn't work: there should be a code issued but I can't see the error. The test tool in PayPal just does the post and doesn't seem to accept any response. I want to see what happened in my script so that I can fix it. How can I get error messages my script outputs?
Any ideas?
Not sure if you tested this already (put at the very beginning of your PHP script):
error_reporting(-1);
ini_set('display_errors', 'On');
if it's not showing, try it with an .htaccess (if on Apache):
php_flag display_errors on
php_value error_reporting -1
with this you should get your error. If not, try your server logs or if it's still don't help, try to echo
some control values to find where it crash...
Of course this is only for debugging purpose and you should turn that OFF when in production.
A better approach would be to log the errors to a file, and not the 'screen'. If you make a server wide change, it's probable that other sites on the server will be affected.
Failing all of the above, install xdebug and try debugging the code - you can step through line by line and inspect variables at will - perhaps this will give you a better idea.
Failing that, resort to var_dump() and friends.
In these sort of cases, you should see what the $_POST
array is printing in the console. Try using the following code at the very beginning of your page, after initializing with all the required configurations:-
<?php
// include all required configurations
// if needed, include the header file also
echo '<pre>';
print_r($_POST); // for viewing it as an array
var_dump($_POST); // for viewing all info of the array
echo '</pre>';
die();
// other HTML or PHP Logic follows
?>
If this does not work, then you will need to put some breakpoints, by putting some "exit
" statements after some code every now & then, and slowly execute as much code as possible in a step-by-step manner.
Hope it helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With