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 --- includes/functions.php | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'includes/functions.php') diff --git a/includes/functions.php b/includes/functions.php index edb666b..e0a5ab8 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -2,9 +2,12 @@ function has_meta($id, $name) { - $getmeta = "SELECT * FROM meta WHERE comic_id = " . $id . " AND name = \"" . $name . "\""; - $getmeta2 = mysql_query($getmeta); - $getmeta3 = mysql_fetch_array($getmeta2); + global $mysql_conn; + $getmeta = $mysql_conn->prepare("SELECT * FROM meta WHERE comic_id = ? AND name = ?"); + $getmeta->bind_param("is", $id, $name); + $getmeta->execute(); + $getmeta2 = $getmeta->get_result(); + $getmeta3 = $getmeta2->fetch_assoc(); if ($getmeta3['name'] == $name) { @@ -16,18 +19,21 @@ function has_meta($id, $name) function get_meta($id, $name) { - $getmeta = "SELECT * FROM meta WHERE comic_id = " . $id . " AND name = \"" . $name . "\""; - $getmeta2 = mysql_query($getmeta); - $getmeta3 = mysql_fetch_array($getmeta2); + global $mysql_conn; + $getmeta = $mysql_conn->prepare("SELECT * FROM meta WHERE comic_id = ? AND name = ?"); + $getmeta->bind_param("is", $id, $name); + $getmeta->execute(); + $getmeta2 = $getmeta->get_result(); + $getmeta3 = $getmeta2->fetch_assoc(); return $getmeta3['value']; } function next_comic_id() { - $getcomic = "SELECT * FROM comics WHERE status = \"publish\" ORDER BY comic_id DESC LIMIT 0,1"; - $getcomic2 = mysql_query($getcomic); - $getcomic3 = mysql_fetch_array($getcomic2); + global $mysql_conn; + $getcomic = $mysql_conn->query("SELECT * FROM comics WHERE status = \"publish\" ORDER BY comic_id DESC LIMIT 0,1"); + $getcomic3 = $getcomic->fetch_assoc(); return ($getcomic3['comic_id']+1); } -- cgit 1.4.1