MySQL -> MySQLi changes begun

It was throwing an error about MySQL being depreciated with Connect and
suggesting a move to MySQLi
This commit is contained in:
jcreek
2014-11-04 00:42:47 +00:00
parent c07ae83d8c
commit 8c4f48a73d
2 changed files with 7 additions and 7 deletions
+2 -2
View File
@@ -11,7 +11,7 @@ $dbname = "assassins"; // the name of the database that you are going to use for
$dbuser = "root"; // the username that you created, or were given, to access your database $dbuser = "root"; // the username that you created, or were given, to access your database
$dbpass = "root"; // the password that you created, or were given, to access your database $dbpass = "root"; // the password that you created, or were given, to access your database
mysql_connect($dbhost, $dbuser, $dbpass) or die("MySQL Error: " . mysql_error()); mysqli_connect($dbhost, $dbuser, $dbpass) or die("MySQL Error: " . mysqli_error());
mysql_select_db($dbname) or die("MySQL Error: " . mysql_error()); mysqli_select_db($dbname) or die("MySQL Error: " . mysqli_error());
//echo "success in database connection."; //Uncomment this line if you want to check if a page is loading this database connection code //echo "success in database connection."; //Uncomment this line if you want to check if a page is loading this database connection code
?> ?>
+5 -5
View File
@@ -2,8 +2,8 @@
<?php <?php
//get the number of rows in the table *THIS WORKS //get the number of rows in the table *THIS WORKS
function GetNumberOfRows() { function GetNumberOfRows() {
$result = mysql_query( "select count(UserID) as num_rows from users" ); $result = mysqli_query( "select count(UserID) as num_rows from users" );
$row = mysql_fetch_object( $result ); $row = mysqli_fetch_object( $result );
$total = $row->num_rows; $total = $row->num_rows;
return $total; return $total;
} }
@@ -174,14 +174,14 @@ function GetNumberOfRows() {
$username = mysql_real_escape_string($_POST['username']); $username = mysql_real_escape_string($_POST['username']);
$password = md5(mysql_real_escape_string($_POST['password'])); $password = md5(mysql_real_escape_string($_POST['password']));
$checklogin = mysql_query("SELECT * FROM users WHERE Username = '".$username."' AND Password = '".$password."'"); $checklogin = mysqli_query("SELECT * FROM users WHERE Username = '".$username."' AND Password = '".$password."'");
//Get the number of players and send it to a session variable //Get the number of players and send it to a session variable
$numberofplayers = GetNumberOfRows(); $numberofplayers = GetNumberOfRows();
$_SESSION['NumberOfPlayers'] = $numberofplayers; $_SESSION['NumberOfPlayers'] = $numberofplayers;
//Get the number of players with 'Alive' as their 'Status' and send that to a session variable //Get the number of players with 'Alive' as their 'Status' and send that to a session variable
$getplayersalive = mysql_query("SELECT * FROM users WHERE Status = 'Alive'"); $getplayersalive = mysqli_query("SELECT * FROM users WHERE Status = 'Alive'");
$numberofplayersalive = mysql_num_rows($getplayersalive); $numberofplayersalive = mysql_num_rows($getplayersalive);
$_SESSION['NumberOfPlayersAlive'] = $numberofplayersalive; $_SESSION['NumberOfPlayersAlive'] = $numberofplayersalive;
@@ -220,7 +220,7 @@ function GetNumberOfRows() {
//Now set the Target Information //Now set the Target Information
//Query the database for the user with 'AssassinID'=$targetID and then //Query the database for the user with 'AssassinID'=$targetID and then
$targetinfo = mysql_query("SELECT * FROM users WHERE AssassinID = '".$targetid."'"); $targetinfo = mysqli_query("SELECT * FROM users WHERE AssassinID = '".$targetid."'");
if(mysql_num_rows($targetinfo) == 1) if(mysql_num_rows($targetinfo) == 1)
{ {