prepare( "INSERT INTO audit_events (user_id, action, target_type, target_id) VALUES (?, ?, ?, ?)" ); $stmt->execute([$userId, $action, $targetType, $targetId]); } catch (PDOException $e) { // In a real application, you would log this error to a file or monitoring service. // For this example, we'll fail silently to not disrupt the user experience. error_log('Audit log failed: ' . $e->getMessage()); } } ?>