From 459e929311d8806f604c0b914ba4b37aa731fbfc Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Mon, 8 Jan 2024 21:09:05 +0000 Subject: Migrated to mysqli --- pages/comic.php | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'pages/comic.php') diff --git a/pages/comic.php b/pages/comic.php index 620a038..53b0538 100755 --- a/pages/comic.php +++ b/pages/comic.php @@ -2,12 +2,16 @@ if (isset($_GET['id']) && is_numeric($_GET['id'])) { - $getcomic = "SELECT * FROM comics WHERE comic_id = " . $_GET['id'] . " AND status = \"publish\""; + $getcomic = $mysql_conn->prepare("SELECT * FROM comics WHERE comic_id = ? AND status = \"publish\""); + $comic_id = $_GET['id']; + $getcomic->bind_param("i", $comic_id); + $getcomic->execute(); + $getcomic2 = $getcomic->get_result(); + $getcomic3 = $getcomic2->fetch_assoc(); } else { - $getcomic = "SELECT * FROM comics WHERE status = \"publish\" ORDER BY comic_id DESC LIMIT 0,1"; + $getcomic = $mysql_conn->query("SELECT * FROM comics WHERE status = \"publish\" ORDER BY comic_id DESC LIMIT 0,1"); + $getcomic3 = $getcomic->fetch_assoc(); } -$getcomic2 = mysql_query($getcomic); -$getcomic3 = mysql_fetch_array($getcomic2); $date = strtotime(get_meta($getcomic3['id'], 'pubDate')); @@ -64,9 +68,8 @@ if (has_meta($getcomic3['id'], 'link')) $id = $getcomic3['comic_id']; -$cntcomics = "SELECT COUNT(*) FROM comics WHERE status = \"publish\""; -$cntcomics2 = mysql_query($cntcomics); -$cntcomics3 = mysql_fetch_array($cntcomics2); +$cntcomics = $mysql_conn->query("SELECT COUNT(*) FROM comics WHERE status = \"publish\""); +$cntcomics3 = $cntcomics->fetch_assoc(); $all = $cntcomics3['COUNT(*)']; if ($id > 2) @@ -98,9 +101,8 @@ if ($id < $all) } } -$cntpending = "SELECT COUNT(*) FROM comics WHERE status = \"pending\""; -$cntpending2 = mysql_query($cntpending); -$cntpending3 = mysql_fetch_array($cntpending2); +$cntpending = $mysql_conn->query("SELECT COUNT(*) FROM comics WHERE status = \"pending\""); +$cntpending3 = $cntpending->fetch_assoc(); $numpending = $cntpending3['COUNT(*)']; ?> -- cgit 1.4.1