From f334835eed779f5640c24ebe8cbd1e8dc0ed0318 Mon Sep 17 00:00:00 2001 From: Dimitris T <56406468+dimitrist19@users.noreply.github.com> Date: Sat, 29 Jan 2022 16:24:58 +0200 Subject: [PATCH] Fix #7 - Corrected false mysql query - Improved code --- tutorials.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tutorials.php b/tutorials.php index 80dc568..cd881ab 100644 --- a/tutorials.php +++ b/tutorials.php @@ -83,10 +83,9 @@ '; } } else if (isset($_GET['id'])) { - $getTutorialQuery = sprintf("SELECT CountryCode FROM City WHERE name='%s'", mysqli_real_escape_string($conn, $_GET['id'])); + $getTutorialQuery = sprintf("SELECT * FROM tutorials WHERE id='%s'", mysqli_real_escape_string($conn, $_GET['id'])); $getTutorialById = mysqli_query($conn, $getTutorialQuery); - $singleTutorial = mysqli_fetch_array($getTutorialById); - if (is_null($singleTutorial['id'])) { + if (mysqli_num_rows($getTutorialById) == 0) { echo '
@@ -103,6 +102,7 @@
'; } else { + $singleTutorial = mysqli_fetch_array($getTutorialById); echo '
@@ -120,7 +120,7 @@
'; ?> ' . $singleTutorial['body'] . ''; } }