diff --git a/api/v1/create_output.php b/api/v1/create_output.php index 3d1580469..66c580fd2 100644 --- a/api/v1/create_output.php +++ b/api/v1/create_output.php @@ -21,6 +21,8 @@ else { $return_arr['success'] = "False"; $return_arr['message'] = "Auth success but insert query failed, ensure ALL required variables are provided (and aren't duplicates where applicable) and database schema is up-to-date. Turn on error logging and look for 'undefined index'."; + logApp("API", "Error", "Create query failed on API call to " . escapeSql(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)) . " containing " . count($_POST) . " POST variables" . " via API key " . escapeSql($api_key_name) . " from IP " . escapeSql(getIP()) . " with agent " . escapeSql(getUserAgent())); + // Log any database/schema related errors to the PHP Error log if (mysqli_error($mysqli)) { error_log("API Database Error: " . mysqli_error($mysqli)); diff --git a/api/v1/delete_output.php b/api/v1/delete_output.php index c5748ceca..f76fafbcf 100644 --- a/api/v1/delete_output.php +++ b/api/v1/delete_output.php @@ -18,6 +18,8 @@ else { $return_arr['success'] = "False"; $return_arr['message'] = "Auth success but delete query failed. Ensure ALL required variables are provided and database schema is up-to-date. Most likely cause: asset/client/company ID mismatch."; + logApp("API", "Error", "Delete query failed on API call to " . escapeSql(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)) . " containing " . count($_POST) . " POST variables" . " via API key " . escapeSql($api_key_name) . " from IP " . escapeSql(getIP()) . " with agent " . escapeSql(getUserAgent())); + // Log any database/schema related errors to the PHP Error log if (mysqli_error($mysqli)) { error_log("API Database Error: " . mysqli_error($mysqli)); diff --git a/api/v1/read_output.php b/api/v1/read_output.php index b3dcaa640..5a37854c7 100644 --- a/api/v1/read_output.php +++ b/api/v1/read_output.php @@ -22,6 +22,8 @@ else { $return_arr['success'] = "False"; $return_arr['message'] = "No resource (for this client and company) with the specified parameter(s)."; + logApp("API", "Error", "Read query failed on API call to " . escapeSql(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)) . " containing " . count($_GET) . " GET variables" . " via API key " . escapeSql($api_key_name) . " from IP " . escapeSql(getIP()) . " with agent " . escapeSql(getUserAgent())); + // Log any database/schema related errors to the PHP Error log if (mysqli_error($mysqli)) { error_log("API Database Error: " . mysqli_error($mysqli)); diff --git a/api/v1/update_output.php b/api/v1/update_output.php index ed9402be2..9948bf353 100644 --- a/api/v1/update_output.php +++ b/api/v1/update_output.php @@ -18,6 +18,8 @@ else { $return_arr['success'] = "False"; $return_arr['message'] = "Auth success but update query failed/returned no results. Ensure ALL required variables are provided and database schema is up-to-date. Most likely cause: non-existent module ID (i.e. bad contact ID/ticket ID/etc) or no rows changed."; + logApp("API", "Error", "Update query failed on API call to " . escapeSql(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)) . " containing " . count($_POST) . " POST variables" . " via API key " . escapeSql($api_key_name) . " from IP " . escapeSql(getIP()) . " with agent " . escapeSql(getUserAgent())); + // Log any database/schema related errors to the PHP Error log if (mysqli_error($mysqli)) { error_log("API Database Error: " . mysqli_error($mysqli));