Error on using Update query in "Action After View"
Hello! I'm new user in this important tool. I am using XAMPP (PHP and MySQL with apache server). I can access the bank and show the results in the "LIST" area. But I'm trying to do the following:
When user go to "VIEW" (details of the record) the script update a database to save the active user name to an field. So I can know who accessed this record. For this I use the following code in the "Action After View" section :
$ActiveUser = ucwords(USER_NAME);
$my_id = $rec_id;
$db->rawQuery("UPDATE mail SET gc_receivedByName='$ActiveUser' WHERE gc_id='$my_id'");
mail -> is my table name.
gc_receivedByName-> is the field that I want to perform the update (belongs to mail table)
$ActiveUser -> gets the name of the logged user
gc_id -> is an another field of the mail table
$my_id -> is the $rec_id
When executing this code the database is updated correctly. There are no mistakes in the DB. However When i are going to a "View" page (record details)iI get the following error (in admin panel): !Error Processing Request.
After the error, no data is obtained from the database. Inspecting the code (in browser), I get the following return: Failed to load resource: the server responded with a status of 500 (Internal Server Error).
Referring to the following location:
http://localhost/mysite/mail/view/1. If I delete the code from the "Action After View" section all results are retrieved from the database without any problem. The only difference I noticed between the two addresses (the address with the update code and the address without the update code) was the following:
With the update query: The link shown in the browser inspector is http://localhost/mysite/mail/view/1 (no data obtained from the database)
With no update query: The link shown in the browser address bar is: http://localhost/agenciavirtual/#/mail/view/1 (data is obtained normally)
Can someone help me?