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/archive.php | 20 ++++++++------------ pages/comic.php | 22 ++++++++++++---------- pages/random.php | 5 ++--- pages/season.php | 19 ++++++++++++------- 4 files changed, 34 insertions(+), 32 deletions(-) (limited to 'pages') diff --git a/pages/archive.php b/pages/archive.php index c5f0f52..114062c 100755 --- a/pages/archive.php +++ b/pages/archive.php @@ -10,25 +10,21 @@ query("SELECT * FROM seasons ORDER BY season_id ASC"); +foreach ($getseasons as $getseasons3) { - $getfc = "SELECT * FROM comics WHERE comic_id = " . $getseasons3['first_comic_id']; - $getfc2 = mysql_query($getfc); - $getfc3 = mysql_fetch_array($getfc2); + $getfc = $mysql_conn->query("SELECT * FROM comics WHERE comic_id = " . $getseasons3['first_comic_id']); + $getfc3 = $getfc->fetch_assoc(); if (!is_null($getseasons3['last_comic_id'])) { - $getlc = "SELECT * FROM comics WHERE comic_id = " . $getseasons3['last_comic_id']; - $getlc2 = mysql_query($getlc); - $getlc3 = mysql_fetch_array($getlc2); + $getlc = $mysql_conn->query("SELECT * FROM comics WHERE comic_id = " . $getseasons3['last_comic_id']); + $getlc3 = $getlc->fetch_assoc(); $count = $getseasons3['last_comic_id'] - ($getseasons3['first_comic_id']-1); } else { - $getcnt = "SELECT COUNT(*) FROM comics WHERE comic_id >= " . $getseasons3['first_comic_id']; - $getcnt2 = mysql_query($getcnt); - $getcnt3 = mysql_fetch_array($getcnt2); + $getcnt = $mysql_conn->query("SELECT COUNT(*) FROM comics WHERE comic_id >= " . $getseasons3['first_comic_id']); + $getcnt3 = $getcnt->fetch_assoc(); $count = $getcnt3[0]; } 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(*)']; ?> diff --git a/pages/random.php b/pages/random.php index 15d7758..049f151 100644 --- a/pages/random.php +++ b/pages/random.php @@ -1,8 +1,7 @@ query("SELECT * FROM comics WHERE status = \"publish\" ORDER BY RAND() LIMIT 1"); +$getcomic3 = $getcomic->fetch_assoc(); header('Location: http://pillowcase.fourisland.com/comic' . $getcomic3['comic_id'] . '.htm'); diff --git a/pages/season.php b/pages/season.php index 74568a0..f47ab13 100755 --- a/pages/season.php +++ b/pages/season.php @@ -2,9 +2,11 @@ if (is_numeric($_GET['season'])) { - $getseason = "SELECT * FROM seasons WHERE season_id = " . $_GET['season']; - $getseason2 = mysql_query($getseason); - $getseason3 = mysql_fetch_array($getseason2); + $getseason = $mysql_conn->prepare("SELECT * FROM seasons WHERE season_id = ?"); + $getseason->bind_param("i", $_GET['season']); + $getseason->execute(); + $getseason2 = $getseason->get_result(); + $getseason3 = $getseason2->fetch_assoc(); } if (isset($getseason3) && ($getseason3['season_id'] == $_GET['season'])) @@ -18,13 +20,16 @@ if (isset($getseason3) && ($getseason3['season_id'] == $_GET['season'])) if (!is_null($getseason3['last_comic_id'])) { - $getcomics = "SELECT * FROM comics WHERE status = \"publish\" AND comic_id >= " . $getseason3['first_comic_id'] . " AND comic_id <= " . $getseason3['last_comic_id'] . " ORDER BY comic_id ASC"; + $getcomics = $mysql_conn->prepare("SELECT * FROM comics WHERE status = \"publish\" AND comic_id >= ? AND comic_id <= ? ORDER BY comic_id ASC"); + $getcomics->bind_param("ii", $getseason3["first_comic_id"], $getseason3["last_comic_id"]); } else { - $getcomics = "SELECT * FROM comics WHERE status = \"publish\" AND comic_id >= " . $getseason3['first_comic_id'] . " ORDER BY comic_id ASC"; + $getcomics = $mysql_conn->prepare("SELECT * FROM comics WHERE status = \"publish\" AND comic_id >= ? ORDER BY comic_id ASC"); + $getcomics->bind_param("i", $getseason3["first_comic_id"]); } -$getcomics2 = mysql_query($getcomics); -while ($getcomics3 = mysql_fetch_array($getcomics2)) +$getcomics->execute(); +$getcomics2 = $getcomics->get_result(); +foreach ($getcomics2 as $getcomics3) { ?>