1
mirror of https://github.com/jakejarvis/spoons.git synced 2025-04-26 06:35:22 -04:00

change all database stuff to MySQLi

This commit is contained in:
Jake Jarvis 2017-07-16 12:43:57 -04:00
parent c89c6821e0
commit 438a9db194
9 changed files with 139 additions and 133 deletions

View File

@ -4,11 +4,11 @@ include('db_connect.php');
include('functions.php');
if($_POST) {
$order = getHighestOrderNum() + 1;
$order = getHighestOrderNum($conn) + 1;
for($i = 0; $i < $_POST['num']; $i++) {
if($_POST['first-' . $i] != "") {
if(!$_POST['staff-' . $i]) $_POST['staff-' . $i] = 0;
mysql_query('INSERT INTO spooners (first, last, order_num, staff) VALUES ("' . mysql_real_escape_string($_POST['first-' . $i]) . '", "' . mysql_real_escape_string($_POST['last-' . $i]) . '", ' . $order . ', ' . mysql_real_escape_string($_POST['staff-' . $i]) . ')') or die(mysql_error());
mysqli_query($conn, 'INSERT INTO spooners (first, last, order_num, staff) VALUES ("' . mysqli_real_escape_string($conn, $_POST['first-' . $i]) . '", "' . mysqli_real_escape_string($conn, $_POST['last-' . $i]) . '", ' . $order . ', ' . mysqli_real_escape_string($conn, $_POST['staff-' . $i]) . ')') or die(mysqli_error($conn));
$order++;
}
}

View File

@ -1,17 +1,26 @@
<?php
/* site config */
$site_url = "http://spoons.scrabblerocks.com";
$site_url = "https://idspoons.herokuapp.com";
$site_password = "asdf1234";
/* database config */
$db_host = "loalhost";
$db_port = 8889;
$db_user = "root";
$db_pass = "lol";
$db_name = "spoons";
if(isset(getenv('JAWSDB_URL'))) {
$db_parts = parse_url(getenv('JAWSDB_URL'));
$db_host = $db_parts['host'];
$db_user = $db_parts['user'];
$db_pass = $db_parts['pass'];
$db_name = ltrim($db_parts['path'],'/');
$db_port = 3306;
} else {
$db_host = "localhost";
$db_port = 8889;
$db_user = "root";
$db_pass = "lol";
$db_name = "spoons";
}
$timezone_number = "-4:00";
$timezone_name = "America/New_York";
date_default_timezone_set($timezone_name);
?>
?>

View File

@ -1,6 +1,17 @@
<?php
mysql_connect($db_host . ":" . $db_port, $db_user, $db_pass);
mysql_select_db($db_name);
//mysql_connect($db_host . ":" . $db_port, $db_user, $db_pass);
//mysql_select_db($db_name);
mysql_query('SET time_zone = "' . $timezone_number . '"');
?>
//mysql_query('SET time_zone = "' . $timezone_number . '"');
// Create connection
$conn = mysqli_connect($db_host, $db_user, $db_pass, $db_name);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
?>

View File

@ -45,20 +45,6 @@
<script src="<?php echo $site_url ?>/assets/js/bootstrap-collapse.js"></script>
<script src="<?php echo $site_url ?>/assets/js/bootstrap-carousel.js"></script>
<script src="<?php echo $site_url ?>/assets/js/bootstrap-typeahead.js"></script>
<script type="text/javascript">
var _gauges = _gauges || [];
(function() {
var t = document.createElement('script');
t.type = 'text/javascript';
t.async = true;
t.id = 'gauges-tracker';
t.setAttribute('data-site-id', '517087f5613f5d77c300005e');
t.src = '//secure.gaug.es/track.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(t, s);
})();
</script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){

View File

@ -1,64 +1,64 @@
<?php
function logSMS($message, $response, $number) {
mysql_query('INSERT INTO texts (message, response, phone_number) VALUES ("' . mysql_real_escape_string($message) . '", "' . mysql_real_escape_string($response) . '", "' . mysql_real_escape_string($number) . '")');
function logSMS($message, $response, $number, $conn) {
mysqli_query($conn, 'INSERT INTO texts (message, response, phone_number) VALUES ("' . mysqli_real_escape_string($conn, $message) . '", "' . mysqli_real_escape_string($conn, $response) . '", "' . mysqli_real_escape_string($conn, $number) . '")');
}
function getNumTotalSpooners() {
$result = mysql_query("SELECT id FROM spooners");
return mysql_num_rows($result);
function getNumTotalSpooners($conn) {
$result = mysqli_query($conn, "SELECT id FROM spooners");
return mysqli_num_rows($result);
}
function getNumActiveSpooners() {
$result = mysql_query("SELECT id FROM spooners WHERE spooned = 0");
return mysql_num_rows($result);
function getNumActiveSpooners($conn) {
$result = mysqli_query($conn, "SELECT id FROM spooners WHERE spooned = 0");
return mysqli_num_rows($result);
}
function getNumActiveCamperSpooners() {
$result = mysql_query("SELECT id FROM spooners WHERE spooned = 0 AND staff = 0");
return mysql_num_rows($result);
function getNumActiveCamperSpooners($conn) {
$result = mysqli_query($conn, "SELECT id FROM spooners WHERE spooned = 0 AND staff = 0");
return mysqli_num_rows($result);
}
function getNumActiveStaffSpooners() {
$result = mysql_query("SELECT id FROM spooners WHERE spooned = 0 AND staff = 1");
return mysql_num_rows($result);
function getNumActiveStaffSpooners($conn) {
$result = mysqli_query($conn, "SELECT id FROM spooners WHERE spooned = 0 AND staff = 1");
return mysqli_num_rows($result);
}
function getLowestOrderNum() {
$result = mysql_query("SELECT order_num FROM spooners WHERE spooned = 0 ORDER BY order_num ASC LIMIT 1");
$spooner = mysql_fetch_array($result);
function getLowestOrderNum($conn) {
$result = mysqli_query($conn, "SELECT order_num FROM spooners WHERE spooned = 0 ORDER BY order_num ASC LIMIT 1");
$spooner = mysqli_fetch_array($result);
return $spooner['order_num'];
}
function getHighestOrderNum() {
$result = mysql_query("SELECT order_num FROM spooners WHERE spooned = 0 ORDER BY order_num DESC LIMIT 1");
$spooner = mysql_fetch_array($result);
function getHighestOrderNum($conn) {
$result = mysqli_query($conn, "SELECT order_num FROM spooners WHERE spooned = 0 ORDER BY order_num DESC LIMIT 1");
$spooner = mysqli_fetch_array($result);
return $spooner['order_num'];
}
function getCamperIDs(){
function getCamperIDs($conn){
$camper_ids = array();
$result = mysql_query("SELECT id FROM spooners WHERE spooned = 0 AND staff = 0 ORDER BY id");
while($spooner = mysql_fetch_array($result)) {
$result = mysqli_query($conn, "SELECT id FROM spooners WHERE spooned = 0 AND staff = 0 ORDER BY id");
while($spooner = mysqli_fetch_array($result)) {
array_push($camper_ids, $spooner['id']);
}
return $camper_ids;
}
function getStaffIDs(){
function getStaffIDs($conn){
$staff_ids = array();
$result = mysql_query("SELECT id FROM spooners WHERE spooned = 0 AND staff = 1 ORDER BY id");
while($spooner = mysql_fetch_array($result)) {
$result = mysqli_query($conn, "SELECT id FROM spooners WHERE spooned = 0 AND staff = 1 ORDER BY id");
while($spooner = mysqli_fetch_array($result)) {
array_push($staff_ids, $spooner['id']);
}
return $staff_ids;
}
function shuffleSpooners() {
$camper_ids = getCamperIDs();
$staff_ids = getStaffIDs();
function shuffleSpooners($conn) {
$camper_ids = getCamperIDs($conn);
$staff_ids = getStaffIDs($conn);
shuffle($camper_ids);
shuffle($staff_ids);
@ -70,7 +70,7 @@ function shuffleSpooners() {
$spacing = round(count($camper_ids)/count($staff_ids))+1;
while(count($random_ids) < getNumActiveSpooners()){
while(count($random_ids) < getNumActiveSpooners($conn)){
for($i = 0; $i < $spacing-1; $i++){
array_push($random_ids, array_pop($camper_ids));
}
@ -89,48 +89,48 @@ function shuffleSpooners() {
}
$result = mysql_query("SELECT id FROM spooners WHERE spooned = 0 ORDER BY id");
$result = mysqli_query($conn, "SELECT id FROM spooners WHERE spooned = 0 ORDER BY id");
for ($i=0; $spooner = mysql_fetch_array($result); $i++) {
mysql_query("UPDATE spooners SET order_num = " . $i . " WHERE id = " . $random_ids[$i]);
for ($i=0; $spooner = mysqli_fetch_array($result); $i++) {
mysqli_query($conn, "UPDATE spooners SET order_num = " . $i . " WHERE id = " . $random_ids[$i]);
}
}
function getIDByLooseName($subject) {
function getIDByLooseName($subject, $conn) {
$subject = trim($subject);
$subject = strtolower($subject);
$subject = str_replace(".", "", $subject); // remove periods
// subject only contains one word
if(substr_count($subject, " ") == 0) {
$result = mysql_query('SELECT id FROM spooners WHERE LOWER(first) = "' . $subject . '"');
if(mysql_num_rows($result) == 1) {
$spooner = mysql_fetch_array($result);
$result = mysqli_query($conn, 'SELECT id FROM spooners WHERE LOWER(first) = "' . $subject . '"');
if(mysqli_num_rows($result) == 1) {
$spooner = mysqli_fetch_array($result);
return $spooner['id']; // MATCH!
} else if(mysql_num_rows($result) > 1) {
} else if(mysqli_num_rows($result) > 1) {
return "multiple"; // more than one found
}
} else if(substr_count($subject, " ") == 1) { // one space, let's assume first space last
$first = substr($subject, 0, strpos($subject, " "));
$last = substr($subject, strpos($subject, " ") + 1);
if(strlen($last) == 1) { // last initial
$result = mysql_query('SELECT id FROM spooners WHERE LOWER(first) = "' . $first . '" AND LOWER(SUBSTRING(last, 1, 1)) = "' . $last . '"');
if(mysql_num_rows($result) > 0) {
$spooner = mysql_fetch_array($result);
$result = mysqli_query($conn, 'SELECT id FROM spooners WHERE LOWER(first) = "' . $first . '" AND LOWER(SUBSTRING(last, 1, 1)) = "' . $last . '"');
if(mysqli_num_rows($result) > 0) {
$spooner = mysqli_fetch_array($result);
return $spooner['id']; // MATCH!
}
} else { // full last name
$result = mysql_query('SELECT id FROM spooners WHERE LOWER(first) = "' . $first . '" AND LOWER(last) = "' . $last . '"');
if(mysql_num_rows($result) > 0) {
$spooner = mysql_fetch_array($result);
$result = mysqli_query($conn, 'SELECT id FROM spooners WHERE LOWER(first) = "' . $first . '" AND LOWER(last) = "' . $last . '"');
if(mysqli_num_rows($result) > 0) {
$spooner = mysqli_fetch_array($result);
return $spooner['id']; // MATCH!
}
}
// still not found, take whole subject and compare to concatenated first + last in database
$result = mysql_query('SELECT id FROM spooners WHERE LOWER(CONCAT_WS(" ", first, last)) = "' . $subject . '"');
if(mysql_num_rows($result) > 0) {
$spooner = mysql_fetch_array($result);
$result = mysqli_query($conn, 'SELECT id FROM spooners WHERE LOWER(CONCAT_WS(" ", first, last)) = "' . $subject . '"');
if(mysqli_num_rows($result) > 0) {
$spooner = mysqli_fetch_array($result);
return $spooner['id'];
}
}
@ -138,11 +138,11 @@ function getIDByLooseName($subject) {
return "none";
}
function getNameByID($id) {
function getNameByID($id, $conn) {
if($id) {
$result = mysql_query("SELECT first, last FROM spooners WHERE id = " . $id) or die(mysql_error());
if(mysql_num_rows($result) == 1) {
$spooner = mysql_fetch_array($result);
$result = mysqli_query($conn, "SELECT first, last FROM spooners WHERE id = " . $id) or die(mysqli_error());
if(mysqli_num_rows($result) == 1) {
$spooner = mysqli_fetch_array($result);
$name = $spooner['first'];
if($spooner['last']) $name .= ' ' . $spooner['last'];
return $name;
@ -152,64 +152,64 @@ function getNameByID($id) {
}
}
function getFirstNameByID($id) {
$result = mysql_query("SELECT first FROM spooners WHERE id = " . $id);
$spooner = mysql_fetch_array($result);
function getFirstNameByID($id, $conn) {
$result = mysqli_query($conn, "SELECT first FROM spooners WHERE id = " . $id);
$spooner = mysqli_fetch_array($result);
return $spooner['first'];
}
function getTargetByID($id) {
$result = mysql_query("SELECT order_num FROM spooners WHERE id = " . $id);
$spooner = mysql_fetch_array($result);
if($spooner['order_num'] == getHighestOrderNum()) { // if last person in the list
$result2 = mysql_query("SELECT id FROM spooners WHERE spooned = 0 AND order_num = " . getLowestOrderNum());
$spooner2 = mysql_fetch_array($result2);
function getTargetByID($id, $conn) {
$result = mysqli_query($conn, "SELECT order_num FROM spooners WHERE id = " . $id);
$spooner = mysqli_fetch_array($result);
if($spooner['order_num'] == getHighestOrderNum($conn)) { // if last person in the list
$result2 = mysqli_query($conn, "SELECT id FROM spooners WHERE spooned = 0 AND order_num = " . getLowestOrderNum($conn));
$spooner2 = mysqli_fetch_array($result2);
return $spooner2['id'];
} else {
$result2 = mysql_query("SELECT id FROM spooners WHERE spooned = 0 AND order_num > " . $spooner['order_num'] . " ORDER BY order_num ASC LIMIT 1");
$spooner2 = mysql_fetch_array($result2);
$result2 = mysqli_query($conn, "SELECT id FROM spooners WHERE spooned = 0 AND order_num > " . $spooner['order_num'] . " ORDER BY order_num ASC LIMIT 1");
$spooner2 = mysqli_fetch_array($result2);
return $spooner2['id'];
}
}
function getReverseTargetByID($id) { // aka get the person above the passed in person
$result = mysql_query("SELECT order_num FROM spooners WHERE id = " . $id);
$spooner = mysql_fetch_array($result);
if($spooner['order_num'] == getLowestOrderNum()) { // if first person in the list
$result2 = mysql_query("SELECT id FROM spooners WHERE spooned = 0 AND order_num = " . getHighestOrderNum());
$spooner2 = mysql_fetch_array($result2);
function getReverseTargetByID($id, $conn) { // aka get the person above the passed in person
$result = mysqli_query($conn, "SELECT order_num FROM spooners WHERE id = " . $id);
$spooner = mysqli_fetch_array($result);
if($spooner['order_num'] == getLowestOrderNum($conn)) { // if first person in the list
$result2 = mysqli_query($conn, "SELECT id FROM spooners WHERE spooned = 0 AND order_num = " . getHighestOrderNum($conn));
$spooner2 = mysqli_fetch_array($result2);
return $spooner2['id'];
} else {
$result2 = mysql_query("SELECT id FROM spooners WHERE spooned = 0 AND order_num < " . $spooner['order_num'] . " ORDER BY order_num DESC LIMIT 1");
$spooner2 = mysql_fetch_array($result2);
$result2 = mysqli_query($conn, "SELECT id FROM spooners WHERE spooned = 0 AND order_num < " . $spooner['order_num'] . " ORDER BY order_num DESC LIMIT 1");
$spooner2 = mysqli_fetch_array($result2);
return $spooner2['id'];
}
}
function checkSpoonedByID($id) {
$result = mysql_query("SELECT spooned FROM spooners WHERE id = " . $id);
$spooner = mysql_fetch_array($result);
function checkSpoonedByID($id, $conn) {
$result = mysqli_query($conn, "SELECT spooned FROM spooners WHERE id = " . $id);
$spooner = mysqli_fetch_array($result);
return $spooner['spooned'];
}
function spoonByID($id) {
mysql_query('SET time_zone = "' . $timezone_number . '"');
mysql_query("UPDATE spooners SET spooned_by = " . getReverseTargetByID($id) . ", time_spooned = NOW(), spooned = 1, order_num = -1 WHERE id = " . $id);
function spoonByID($id, $conn) {
mysqli_query($conn, 'SET time_zone = "' . $timezone_number . '"');
mysqli_query($conn, "UPDATE spooners SET spooned_by = " . getReverseTargetByID($id, $conn) . ", time_spooned = NOW(), spooned = 1, order_num = -1 WHERE id = " . $id);
}
function reviveByID($id) {
mysql_query("UPDATE spooners SET spooned = 0, order_num = " . (getHighestOrderNum() + 1) . " WHERE id = " . $id);
function reviveByID($id, $conn) {
mysqli_query($conn, "UPDATE spooners SET spooned = 0, order_num = " . (getHighestOrderNum($conn) + 1) . " WHERE id = " . $id);
}
function getSpoonedByIDByID($id) {
$result = mysql_query("SELECT spooned_by FROM spooners WHERE id = " . $id);
$spooner = mysql_fetch_array($result);
function getSpoonedByIDByID($id, $conn) {
$result = mysqli_query($conn, "SELECT spooned_by FROM spooners WHERE id = " . $id);
$spooner = mysqli_fetch_array($result);
return $spooner['spooned_by'];
}
function getTimeSpoonedByID($id) {
$result = mysql_query("SELECT time_spooned FROM spooners WHERE id = " . $id);
$spooner = mysql_fetch_array($result);
function getTimeSpoonedByID($id, $conn) {
$result = mysqli_query($conn, "SELECT time_spooned FROM spooners WHERE id = " . $id);
$spooner = mysqli_fetch_array($result);
return $spooner['time_spooned'];
}

View File

@ -163,7 +163,7 @@
<link href="<?php echo $site_url ?>/assets/css/bootstrap-responsive.css" rel="stylesheet">
<!-- Pretty font -->
<script type="text/javascript" src="http://use.typekit.com/zhe6udw.js"></script>
<script type="text/javascript" src="https://use.typekit.com/zhe6udw.js"></script>
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
<!-- Le JQuery -->

View File

@ -3,10 +3,10 @@ include('init.php');
// needs to be at top so we can redirect to prevent double-shuffling or double-clearing
if(isset($_GET['shuffle']) && isset($_GET['confirmed'])) {
shuffleSpooners();
shuffleSpooners($conn);
header("Location:" . $site_url . "/shuffle/done");
} else if(isset($_GET['clear']) && isset($_GET['confirmed'])) {
mysql_query("TRUNCATE spooners");
mysqli_query($conn, "TRUNCATE spooners");
header("Location:" . $site_url . "/clear/done");
}
@ -103,21 +103,21 @@ h2, h4{
/*********** SPOONING **********/
if(isset($_GET['spoon'])) {
spoonByID($_GET['spoon']);
spoonByID($_GET['spoon'], $conn);
?>
<div class="alert">
<button type="button" class="close" data-dismiss="alert">&times;</button>
<h4><strong><?php echo getNameByID($_GET['spoon']) ?></strong> has been spooned! <?php echo getNameByID(getSpoonedByIDByID($_GET['spoon'])) ?></strong>'s new target is <?php echo getNameByID(getTargetByID(getSpoonedByIDByID($_GET['spoon']))) ?>.</h4>
<h4><strong><?php echo getNameByID($_GET['spoon'], $conn) ?></strong> has been spooned! <?php echo getNameByID(getSpoonedByIDByID($_GET['spoon'], $conn), $conn) ?></strong>'s new target is <?php echo getNameByID(getTargetByID(getSpoonedByIDByID($_GET['spoon'], $conn), $conn), $conn) ?>.</h4>
</div>
<?php
}
if(isset($_GET['revive'])) {
reviveByID($_GET['revive']);
reviveByID($_GET['revive'], $conn);
?>
<div class="alert">
<button type="button" class="close" data-dismiss="alert">&times;</button>
<h4><strong><?php echo getNameByID($_GET['revive']) ?></strong> has been revived, but note that he or she has been added to the end of the list.</h4>
<h4><strong><?php echo getNameByID($_GET['revive'], $conn) ?></strong> has been revived, but note that he or she has been added to the end of the list.</h4>
<p>It's recommended to drag the revived spooner below a staff member so that you don't have to tell a camper that his or her target has changed for no reason.</p>
</div>
<?php
@ -198,12 +198,12 @@ $(document).ready(function() {
</script>
<?php
$result = mysql_query("SELECT id, first, last, staff FROM spooners WHERE spooned = 0 ORDER BY order_num") or die(mysql_error());
$result = mysqli_query($conn, "SELECT id, first, last, staff FROM spooners WHERE spooned = 0 ORDER BY order_num") or die(mysqli_error($conn));
?>
<h4>Active Spooners (<?php echo mysql_num_rows($result) ?>)</h4>
<h4>Active Spooners (<?php echo mysqli_num_rows($result) ?>)</h4>
<?php if(mysql_num_rows($result) > 0) { ?>
<?php if(mysqli_num_rows($result) > 0) { ?>
<table class="table table-active">
<thead>
<tr class="row">
@ -215,7 +215,7 @@ $result = mysql_query("SELECT id, first, last, staff FROM spooners WHERE spooned
</thead>
<tbody>
<?php
while($spooner = mysql_fetch_array($result)) {
while($spooner = mysqli_fetch_array($result)) {
echo ' <tr id="' . $spooner['id'] . '" class="row';
if($spooner['staff']) echo ' success'; // highlight staff with green row
echo '">
@ -223,7 +223,7 @@ $result = mysql_query("SELECT id, first, last, staff FROM spooners WHERE spooned
<td>' . $spooner['first'] . '</td>
<td>' . $spooner['last'] . '</td>
<td class="drag align-center"><i class="icon-list"></i></td>
<!-- <td><small>Targeting ' . getNameByID(getTargetByID($spooner['id'])) . ', targeted by ' . getNameByID(getReverseTargetByID($spooner['id'])) . '</small></td> -->
<!-- <td><small>Targeting ' . getNameByID(getTargetByID($spooner['id'], $conn), $conn) . ', targeted by ' . getNameByID(getReverseTargetByID($spooner['id'], $conn), $conn) . '</small></td> -->
</tr>
';
}
@ -237,12 +237,12 @@ $result = mysql_query("SELECT id, first, last, staff FROM spooners WHERE spooned
<hr>
<?php
$result = mysql_query("SELECT id, first, last, staff, spooned_by, time_spooned FROM spooners WHERE spooned = 1 ORDER BY time_spooned DESC") or die(mysql_error());
$result = mysqli_query($conn, "SELECT id, first, last, staff, spooned_by, time_spooned FROM spooners WHERE spooned = 1 ORDER BY time_spooned DESC") or die(mysqli_error($conn));
?>
<h4>Dead Spooners (<?php echo mysql_num_rows($result) ?>)</h4>
<h4>Dead Spooners (<?php echo mysqli_num_rows($result) ?>)</h4>
<?php if(mysql_num_rows($result) > 0) { ?>
<?php if(mysqli_num_rows($result) > 0) { ?>
<table class="table table-inactive">
<thead>
<tr class="row">
@ -254,14 +254,14 @@ $result = mysql_query("SELECT id, first, last, staff, spooned_by, time_spooned F
</thead>
<tbody>
<?php
while($spooner = mysql_fetch_array($result)) {
while($spooner = mysqli_fetch_array($result)) {
echo ' <tr id="' . $spooner['id'] . '" class="row';
if($spooner['staff']) echo ' success'; // highlight staff with green row
echo '">
<td class="align-center" style="min-width:40px;"><a href="' . $site_url . '/revive/' . $spooner['id'] . '" class="btn hidden-phone" type="submit"><i class="icon-arrow-up"></i> Revive</a><a href="' . $site_url . '/revive/' . $spooner['id'] . '" class="btn visible-phone" style="padding-left:10px !important; width:40px !important;"> <i class="icon-arrow-up"></i></a></td>
<td>' . $spooner['first'] . ' ' . $spooner['last'] . '</td>
<td class="hidden-phone"><small>Spooned by <strong>' . getNameByID($spooner['spooned_by']) . '</strong> on <strong>' . date('l', strtotime($spooner['time_spooned'])) . '</strong> at <strong>' . date('g:i A', strtotime($spooner['time_spooned'])) . '</strong>.</small></td>
<td class="visible-phone"><small>Spooned by <strong>' . getNameByID($spooner['spooned_by']) . '</strong></br> on <strong>' . date('l', strtotime($spooner['time_spooned'])) . '</strong> at <strong>' . date('g:i A', strtotime($spooner['time_spooned'])) . '</strong>.</small></td>
<td class="hidden-phone"><small>Spooned by <strong>' . getNameByID($spooner['spooned_by'], $conn) . '</strong> on <strong>' . date('l', strtotime($spooner['time_spooned'])) . '</strong> at <strong>' . date('g:i A', strtotime($spooner['time_spooned'])) . '</strong>.</small></td>
<td class="visible-phone"><small>Spooned by <strong>' . getNameByID($spooner['spooned_by'], $conn) . '</strong></br> on <strong>' . date('l', strtotime($spooner['time_spooned'])) . '</strong> at <strong>' . date('g:i A', strtotime($spooner['time_spooned'])) . '</strong>.</small></td>
</tr>
';

View File

@ -9,10 +9,10 @@ if(!isset($_SESSION['logged_in']) || $_SESSION['logged_in'] == FALSE) {
include('db_connect.php');
$result = mysql_query("SELECT first, last FROM spooners WHERE spooned = 0 ORDER BY order_num") or die(mysql_error());
$result = mysqli_query($conn, "SELECT first, last FROM spooners WHERE spooned = 0 ORDER BY order_num") or die(mysqli_error($conn));
$i = 0;
while($spooner = mysql_fetch_array($result)) {
while($spooner = mysqli_fetch_array($result)) {
$spooners[$i]['name'] = $spooner['first'];
if($spooner['last']) $spooners[$i]['name'] .= " " . $spooner['last'];

View File

@ -5,6 +5,6 @@ include('db_connect.php');
$order_array = explode(",", $_POST['order']);
foreach($order_array as $key => $value) {
echo $value . ' > ' . $key . "\n";
mysql_query("UPDATE spooners SET order_num = " . $key . " WHERE id = " . $value) or die(mysql_error());
mysqli_query($conn, ("UPDATE spooners SET order_num = " . $key . " WHERE id = " . $value) or die(mysqli_error($conn));
}
?>