Hi, trying to update another table after saving a record in a form. I am receiving this error:
[TABLE=“width: 0”]
[TR]
[TD=“class: scFormErrorTitleFont”]Error[/TD]
[TD]Close [/TD]
[/TR]
[/TABLE]
Error while accessing the database:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘Date = 2013-02-20 , Encounter = ‘234234234’, Patient Name = ‘Test Any One’ WHERE’ at line 1
The code is as follows in onAfterUpdate:
/**
- Update a record on another table
*/
// SQL statement parameters
$update_table = ‘patient_history’; // Table name
$update_where = “PatientID = {PatientID}”; // Where clause
$update_fields = array( // Field list, add as many as needed
“Entry Date = {Entry Date}”,
“Encounter = ‘{Encounter}’”,
“Patient Name = ‘{Patient Name}’”,
);
// Update record
$update_sql = ‘UPDATE ’ . $update_table
. ’ SET ’ . implode(’, ', $update_fields)
. ’ WHERE ’ . $update_where;
sc_exec_sql($update_sql);
Any help? Thanks,