Check for errors in PHP file executed by external url

Posted on

Question :

Good morning,

I’m working with the checkout service of Cielo and I’m having a problem at the time of processing the url return, that is, the file is called when there is an update in the payment, soon I never directly access the file, it is called through url by own Cielo .

The problem is that I am not able to run some sql codes and I also can not debug them.

When I just check the incoming file I use this code:

$data = $_POST;
$filename = microtime(true);
$fp = fopen($filename.'.json', 'w');
fwrite($fp, json_encode($data));

This generates a file with all data correctly. But when I try something like this:

require_once('server.php'); //Aqui está a conexão com o banco e funções de query
$query = sql('SELECT * FROM ...');

$filename = microtime(true);
$fp = fopen($filename.'.json', 'w');
fwrite($fp, json_encode($query));

No files are written to the server, so I can not see what’s happening.

How can I get around this?


Answer :

I went through the same situation some time ago, and I was able to debug referring to the server log files .

In addition, I used the error_log method of PHP to write custom messages to the logo file in order to facilitate debugging.


Leave a Reply

Your email address will not be published. Required fields are marked *