Page 1 of 1

Table specific hook doesn't seem to work, help and tips for debuging

Posted: 2020-01-06 14:10
by chrisagon
I have read and read again the page https://bigprof.com/appgini/help/advanc ... ific-hooks.
I have modified my tablename.php file in the hook directory. You can see it here : https://github.com/chrisagon/hrcv3/blob ... t.php#L188
I have no error, but I don't understand why I don't even see the echo I have put for debugging purpose and why my code is not executed !? :shock:

What kind of tools do you use for debuging your php file ?
Anyboby have an idea ?

Re: Table specific hook doesn't seem to work, help and tips for debuging

Posted: 2020-01-06 14:45
by pbottcher
Hi,
just put

exit;

after

Code: Select all

echo "<br>apres INSERT&nbsp; Consultant </br>";
like

Code: Select all

echo "<br>apres INSERT&nbsp; Consultant </br>";exit;
Then you should see your text.

The hook file gets executed but will then return with true or false to indicate that the function terminated correctly or not (e.g. instert to be done or not).
Then the page gets reloaded, so that you will not see the output that you produce in the hook itself via echo.

You can e.g. use the "exit;" version, or write your output to a file.

Re: Table specific hook doesn't seem to work, help and tips for debuging

Posted: 2020-01-06 16:31
by chrisagon
YES of course ;) !
Thank you for your help.

Re: Table specific hook doesn't seem to work, help and tips for debuging

Posted: 2020-01-07 10:43
by chrisagon
here is an help for debugging.
You can use "error_log" : https://www.php.net/manual/fr/function.error-log
like this :

Code: Select all

// error message to be logged
$error_message = "Ceci est un message erreur!\r";

// path of the log file where errors need to be logged
$log_file = "./mes-erreurs.log";

// logging error message to given log file
error_log($error_message, 3, $log_file); 
or like this :

Code: Select all

        $error_message = $chemin_cv." Fichier non trouve !";
        error_log($error_message, 3, "./mes-erreurs.log");
This help me to find my bug. :roll: