Use mysqli instead of deprecated mysql module

This commit is contained in:
Ruan 2015-02-21 07:55:15 +02:00
parent 152d1de79a
commit 7780ec2ff6
5 changed files with 18 additions and 19 deletions

View File

@ -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 . ']');
}
?>
<body>
<div class="container">
@ -51,7 +51,7 @@ if (!$retval) {
</tr>
</thead>
<tbody>
<?php while ($row = mysql_fetch_assoc($retval)) {
<?php while($row = $result->fetch_assoc()){
// <<-----------------Ban Date Converter------------>> //
$timeEpoch = $row['time'];
$timeConvert = $timeEpoch / 1000;
@ -75,7 +75,7 @@ if (!$retval) {
} ?></td>
</tr>
<?php }
mysql_close($conn);
$result->free();
echo "</tbody></table>";
?>
</div>

View File

@ -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');
?>

View File

@ -4,5 +4,6 @@
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="jquery-1.10.2" level="application" />
</component>
</module>

View File

@ -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 . ']');
}
?>
<body>
@ -41,7 +40,7 @@ if (!$retval) {
</tr>
</thead>
<tbody>
<?php while ($row = mysql_fetch_assoc($retval)) {
<?php while($row = $result->fetch_assoc()){
// <<-----------------Ban Date Converter------------>> //
$timeEpoch = $row['time'];
$timeConvert = $timeEpoch / 1000;
@ -63,7 +62,7 @@ if (!$retval) {
} ?></td>
</tr>
<?php }
mysql_close($conn);
$result->close();
echo "</tbody></table>";
?>
</div>

View File

@ -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 . ']');
}
?>
<body>
<div class="container">
@ -48,7 +48,7 @@ if (!$retval) {
</tr>
</thead>
<tbody>
<?php while ($row = mysql_fetch_assoc($retval)) {
<?php while($row = $result->fetch_assoc()){
// <<-----------------Expiration Time Converter------------>> //
$expiresEpoch = $row['until'];
$expiresConvert = $expiresEpoch / 1000;
@ -65,7 +65,7 @@ if (!$retval) {
} ?></td>
</tr>
<?php }
mysql_close($conn);
$result->close();
echo "</tbody></table>";
?>
</div>