I have a php query to update a MySQL database, see below
$sql=("update hr_payroll set
payroll_number='$payroll_number',
tax_code='$tax',
bacs_ref='$bacs_ref',
pay_frequency='$pay',
last_update_by='$user'
where employee_id='$employee'")or die('Could not connect: Error 23 ' . mysql_error());
If this query is successful a row is inserted into the DB, see below;
if ($conn->query($sql) === TRUE) {
$sql1 = "INSERT INTO audit_hr_employees
(tab, employee, error_type, user, result)
VALUES ('4a', '$employee', 'info', '$user', 'success')";
}
This all works fine.... However if the query is not successful I want to do the same as above but add the error or the query into the database.
Below is a snippet of my code, I want the information to be added to the error_info
column.
else
{
$sql2 = "INSERT INTO audit_hr_employees
(tab, employee, error_type, user, error_info)
VALUES ('4a', '$employee', 'warning', '$user', ' ')";
}
Is this possible?