From 5e67cf7450f70195a9ada7b7218c5273a89ae9c8 Mon Sep 17 00:00:00 2001 From: Luan Luciano <luanluciano@outlook.com> Date: Sun, 10 Jul 2022 05:07:37 -0300 Subject: [PATCH] Fix error in helpdesk.php (#516) Error: Warning: Trying to access array offset on value of type bool in C:....\helpdesk.php on line 34 If I put a non-existent ID in the URL, it throws the error. --- admin_helpdesk.php | 7 ++++++- helpdesk.php | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/admin_helpdesk.php b/admin_helpdesk.php index fc41a43..5f49cdb 100644 --- a/admin_helpdesk.php +++ b/admin_helpdesk.php @@ -36,6 +36,11 @@ if ($view !== false){ } $ticketData = mysql_select_single("SELECT * FROM znote_tickets WHERE id='$view' LIMIT 1;"); + if(!$ticketData) { + echo 'You can not view this ticket!'; + include 'layout/overall/footer.php'; + die; + } ?> <h1>View Ticket #<?php echo $ticketData['id']; ?></h1> <table class="znoteTable ThreadTable table table-striped"> @@ -144,4 +149,4 @@ if ($view !== false){ } else echo 'No helpdesk tickets has been submitted.'; } include 'layout/overall/footer.php'; -?> \ No newline at end of file +?> diff --git a/helpdesk.php b/helpdesk.php index 51c7134..ab09cf9 100644 --- a/helpdesk.php +++ b/helpdesk.php @@ -21,7 +21,7 @@ if ($view !== false) { } $ticketData = mysql_select_single("SELECT * FROM znote_tickets WHERE id='$view' LIMIT 1;"); - if($ticketData['owner'] != $session_user_id) { + if(!$ticketData || $ticketData['owner'] != $session_user_id) { echo 'You can not view this ticket!'; include 'layout/overall/footer.php'; die;