From 7ea39eb545a025fe9e51693917d48580d7df30ad Mon Sep 17 00:00:00 2001 From: johnnyq Date: Sun, 2 Nov 2025 13:32:44 -0500 Subject: [PATCH] Fix non existent record in contact details, document details, document template, ticket template also add limit 1 --- admin/document_template_details.php | 8 +++++++- admin/project_template_details.php | 4 ++-- admin/ticket_template_details.php | 10 ++++++++-- agent/contact_details.php | 7 +++++++ agent/document_details.php | 9 ++++++++- 5 files changed, 32 insertions(+), 6 deletions(-) diff --git a/admin/document_template_details.php b/admin/document_template_details.php index 1b8ffe7d..47cc9876 100644 --- a/admin/document_template_details.php +++ b/admin/document_template_details.php @@ -15,7 +15,13 @@ if (isset($_GET['document_template_id'])) { $document_template_id = intval($_GET['document_template_id']); } -$sql_document = mysqli_query($mysqli, "SELECT * FROM document_templates WHERE document_template_id = $document_template_id"); +$sql_document = mysqli_query($mysqli, "SELECT * FROM document_templates WHERE document_template_id = $document_template_id LIMIT 1"); + +if (mysqli_num_rows($sql_document) == 0) { + echo "

Nothing to see here

Go Back
"; + require_once "../includes/footer.php"; + exit(); +} $row = mysqli_fetch_array($sql_document); diff --git a/admin/project_template_details.php b/admin/project_template_details.php index 857f1a7b..e8b6a2c6 100644 --- a/admin/project_template_details.php +++ b/admin/project_template_details.php @@ -13,9 +13,9 @@ if (isset($_GET['project_template_id'])) { ); if (mysqli_num_rows($sql_project_templates) == 0) { - echo "

Nothing to see here

Go Back
"; + echo "

Nothing to see here

Go Back
"; - include_once "footer.php"; + require_once "../includes/footer.php"; exit; } diff --git a/admin/ticket_template_details.php b/admin/ticket_template_details.php index 75a7995a..a978fce5 100644 --- a/admin/ticket_template_details.php +++ b/admin/ticket_template_details.php @@ -15,9 +15,15 @@ if (isset($_GET['ticket_template_id'])) { $ticket_template_id = intval($_GET['ticket_template_id']); } -$sql_ticket_templates = mysqli_query($mysqli, "SELECT * FROM ticket_templates WHERE ticket_template_id = $ticket_template_id"); +$sql_ticket_template = mysqli_query($mysqli, "SELECT * FROM ticket_templates WHERE ticket_template_id = $ticket_template_id LIMIT 1"); -$row = mysqli_fetch_array($sql_ticket_templates); +if (mysqli_num_rows($sql_ticket_template) == 0) { + echo "

Nothing to see here

Go Back
"; + require_once "../includes/footer.php"; + exit(); +} + +$row = mysqli_fetch_array($sql_ticket_template); $ticket_template_name = nullable_htmlentities($row['ticket_template_name']); $ticket_template_description = nullable_htmlentities($row['ticket_template_description']); diff --git a/agent/contact_details.php b/agent/contact_details.php index 707e2052..a3420b8c 100644 --- a/agent/contact_details.php +++ b/agent/contact_details.php @@ -20,8 +20,15 @@ if (isset($_GET['contact_id'])) { LEFT JOIN users ON user_id = contact_user_id WHERE contact_id = $contact_id $client_query + LIMIT 1 "); + if (mysqli_num_rows($sql) == 0) { + echo "

Nothing to see here

Go Back
"; + require_once "../includes/footer.php"; + exit(); + } + $row = mysqli_fetch_array($sql); $client_id = intval($row['client_id']); $client_name = nullable_htmlentities($row['client_name']); diff --git a/agent/document_details.php b/agent/document_details.php index ad86884d..db6d150e 100644 --- a/agent/document_details.php +++ b/agent/document_details.php @@ -20,9 +20,16 @@ $folder_location = 0; $sql_document = mysqli_query($mysqli, "SELECT * FROM documents LEFT JOIN folders ON document_folder_id = folder_id LEFT JOIN users ON document_created_by = user_id - WHERE document_client_id = $client_id AND document_id = $document_id" + WHERE document_client_id = $client_id AND document_id = $document_id + LIMIT 1" ); +if (mysqli_num_rows($sql_document) == 0) { + echo "

Nothing to see here

Go Back
"; + require_once "../includes/footer.php"; + exit(); +} + $row = mysqli_fetch_array($sql_document); $folder_name = nullable_htmlentities($row['folder_name']);