From 7780ec2ff6647d6830b62828cf57b9d0c3e7c006 Mon Sep 17 00:00:00 2001 From: Ruan Date: Sat, 21 Feb 2015 07:55:15 +0200 Subject: [PATCH] Use mysqli instead of deprecated mysql module --- bans.php | 10 +++++----- includes/data/database.php | 7 +++---- litebans-php.iml | 1 + mutes.php | 9 ++++----- warnings.php | 10 +++++----- 5 files changed, 18 insertions(+), 19 deletions(-) diff --git a/bans.php b/bans.php index 1499683..271e04e 100644 --- a/bans.php +++ b/bans.php @@ -9,10 +9,10 @@ require 'includes/data/database.php'; $sql = 'SELECT time,until,reason,name,banned_by_name FROM ' . $table_bans . ' INNER JOIN ' . $table_history . ' on ' . $table_bans . '.uuid=' . $table_history . '.uuid WHERE active=1 GROUP BY name ORDER BY time DESC LIMIT 20'; -$retval = mysql_query($sql, $conn); -if (!$retval) { - die('Could not get data: ' . mysql_error($conn)); +if(!$result = $conn->query($sql)) { + die('Query error [' . $conn->error . ']'); } + ?>
@@ -51,7 +51,7 @@ if (!$retval) { - fetch_assoc()){ // <<-----------------Ban Date Converter------------>> // $timeEpoch = $row['time']; $timeConvert = $timeEpoch / 1000; @@ -75,7 +75,7 @@ if (!$retval) { } ?> free(); echo ""; ?>
diff --git a/includes/data/database.php b/includes/data/database.php index 5902a0c..e5ea17d 100644 --- a/includes/data/database.php +++ b/includes/data/database.php @@ -2,7 +2,7 @@ $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = 'password'; -$conn = mysql_connect($dbhost, $dbuser, $dbpass); +$conn = new mysqli($dbhost, $dbuser, $dbpass, 'litebans'); $table_prefix = ""; $table_bans = $table_prefix . "bans"; @@ -10,9 +10,8 @@ $table_mutes = $table_prefix . "mutes"; $table_warnings = $table_prefix . "warnings"; $table_history = $table_prefix . "history"; -if (!$conn) { - die('Could not connect: ' . mysql_error()); +if($conn->connect_errno > 0){ + die('Unable to connect to database [' . $conn->connect_error . ']'); } -mysql_select_db('litebans'); ?> \ No newline at end of file diff --git a/litebans-php.iml b/litebans-php.iml index 80cc739..5e2e934 100644 --- a/litebans-php.iml +++ b/litebans-php.iml @@ -4,5 +4,6 @@ + \ No newline at end of file diff --git a/mutes.php b/mutes.php index ea567bc..ce2ae35 100644 --- a/mutes.php +++ b/mutes.php @@ -9,9 +9,8 @@ require 'includes/data/database.php'; $sql = 'SELECT time,until,reason,name,banned_by_name FROM ' . $table_mutes . ' INNER JOIN ' . $table_history . ' on ' . $table_mutes . '.uuid=' . $table_history . '.uuid WHERE active=1 GROUP BY name ORDER BY time DESC LIMIT 20'; -$retval = mysql_query($sql, $conn); -if (!$retval) { - die('Could not get data: ' . mysql_error()); +if(!$result = $conn->query($sql)) { + die('Query error [' . $conn->error . ']'); } ?> @@ -41,7 +40,7 @@ if (!$retval) { - fetch_assoc()){ // <<-----------------Ban Date Converter------------>> // $timeEpoch = $row['time']; $timeConvert = $timeEpoch / 1000; @@ -63,7 +62,7 @@ if (!$retval) { } ?> close(); echo ""; ?> diff --git a/warnings.php b/warnings.php index faca105..45c69cb 100644 --- a/warnings.php +++ b/warnings.php @@ -9,10 +9,10 @@ require 'includes/data/database.php'; $sql = 'SELECT time,until,reason,name,banned_by_name FROM ' . $table_warnings . ' INNER JOIN ' . $table_history . ' on ' . $table_warnings . '.uuid=' . $table_history . '.uuid WHERE active=1 GROUP BY name ORDER BY time DESC LIMIT 20'; -$retval = mysql_query($sql, $conn); -if (!$retval) { - die('Could not get data: ' . mysql_error($conn)); +if(!$result = $conn->query($sql)) { + die('Query error [' . $conn->error . ']'); } + ?>
@@ -48,7 +48,7 @@ if (!$retval) { - fetch_assoc()){ // <<-----------------Expiration Time Converter------------>> // $expiresEpoch = $row['until']; $expiresConvert = $expiresEpoch / 1000; @@ -65,7 +65,7 @@ if (!$retval) { } ?> close(); echo ""; ?>