Anonymous Anonymous - 1 year ago 55
PHP Question

PHP Undefined Index in Page Receiving ID

I am trying to determined why I am getting and Undefined Index error. I have checked the other posts here o Stack Overflow to no avail.
I am passing an ID to this page and querying the database based on this ID. My database connection is fine, because one of my select boxes is getting populated from a table.
Please help me determine why all 18 elements of my POST array are Undefined.

Notice: Undefined index: location_id in C:\xampp\htdocs\PTMS\update_tournament.php on line 183

Notice: Undefined index: day in C:\xampp\htdocs\PTMS\update_tournament.php on line 184

Notice: Undefined index: time in C:\xampp\htdocs\PTMS\update_tournament.php on line 185

Notice: Undefined index: fee in C:\xampp\htdocs\PTMS\update_tournament.php on line 186

Notice: Undefined index: added in C:\xampp\htdocs\PTMS\update_tournament.php on line 187

Notice: Undefined index: game in C:\xampp\htdocs\PTMS\update_tournament.php on line 188

Notice: Undefined index: race in C:\xampp\htdocs\PTMS\update_tournament.php on line 189

Notice: Undefined index: bih in C:\xampp\htdocs\PTMS\update_tournament.php on line 190

Notice: Undefined index: rule in C:\xampp\htdocs\PTMS\update_tournament.php on line 191

Notice: Undefined index: handicapped in C:\xampp\htdocs\PTMS\update_tournament.php on line 192

Notice: Undefined index: table_size in C:\xampp\htdocs\PTMS\update_tournament.php on line 193

Notice: Undefined index: tables_used in C:\xampp\htdocs\PTMS\update_tournament.php on line 194

Notice: Undefined index: cueball in C:\xampp\htdocs\PTMS\update_tournament.php on line 195

Notice: Undefined index: equipment in C:\xampp\htdocs\PTMS\update_tournament.php on line 196

Notice: Undefined index: noise in C:\xampp\htdocs\PTMS\update_tournament.php on line 197

Notice: Undefined index: space in C:\xampp\htdocs\PTMS\update_tournament.php on line 198

Notice: Undefined index: pots in C:\xampp\htdocs\PTMS\update_tournament.php on line 199

Notice: Undefined index: description in C:\xampp\htdocs\PTMS\update_tournament.php on line 200

<?php
// include configuration file
include 'config/core.php';

// include database connection
include 'config/database.php';

// get passed parameter value, in this case, the record ID
// isset() is a PHP function used to verify if a value is there or not
$id=isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');

// page header
$page_title="Update a Record";
include_once "layout_head.php";

// check if form was submitted
if($_POST){

try{

// data validation
if($_POST['location_id']==0){
echo "<div class='alert alert-danger'>Please select a location.</div>";
}

else if($_POST['day']=="empty"){
echo "<div class='alert alert-danger'>Please select a day.</div>";
}

else if(empty($_POST['fee'])){
echo "<div class='alert alert-danger'>Fee cannot be empty.</div>";
}

else if($_POST['added']=="empty"){
echo "<div class='alert alert-danger'>Please select money added.</div>";
}

else if($_POST['game']=="empty"){
echo "<div class='alert alert-danger'>Please select a game.</div>";
}

else if(empty($_POST['race'])){
echo "<div class='alert alert-danger'>Race cannot be empty.</div>";
}

else if($_POST['handicapped']=="empty"){
echo "<div class='alert alert-danger'>Please select handicapped.</div>";
}

else if($_POST['table_size']=="empty"){
echo "<div class='alert alert-danger'>Please select the tables size.</div>";
}

else if(empty($_POST['tables_used'])){
echo "<div class='alert alert-danger'>Tables used cannot be empty.</div>";
}

else if($_POST['cueball']=="empty"){
echo "<div class='alert alert-danger'>Please select the cueball size.</div>";
}

else if($_POST['equipment']=="empty"){
echo "<div class='alert alert-danger'>Please rate equipment.</div>";
}

else if($_POST['noise']=="empty"){
echo "<div class='alert alert-danger'>Please rate noise.</div>";
}

else if($_POST['space']=="empty"){
echo "<div class='alert alert-danger'>Please rate space.</div>";
}

else if($_POST['cueball']=="empty"){
echo "<div class='alert alert-danger'>Please select the cueball size.</div>";
}

else if($_POST['pots']=="empty"){
echo "<div class='alert alert-danger'>Please select the pots.</div>";
}

else if(empty($_POST['description'])){
echo "<div class='alert alert-danger'>Description cannot be empty.</div>";
}
else{
//write query
//in this case, it seemed like we have so many fields to pass and
//its kinda better if we'll label them and not use question marks
//like what we used here

$query = "Update tournaments ";
$query .= "SET location_id=:location_id, ";
$query .= "day=:day, time=:time, fee=:fee, added=:added, game=:game, race=:race, ";
$query .= "bih=:bih, rule=:rule, handicapped=:handicapped, ";
$query .= "table_size=:table_size, tables_used=:tables_used, cueball=:cueball, ";
$query .= "equipment=:equipment, noise=:noise, space=:space, pots=:pots, description=:description ";
$query .= "WHERE id=:id";

//prepare query for excecution
$stmt = $con->prepare($query);

// bind the parameters
$stmt->bindParam(':location_id', $_POST['location_id']);
$stmt->bindParam(':day', $_POST['day']);
$stmt->bindParam(':time', $_POST['time']);
$stmt->bindParam(':fee', $_POST['fee']);
$stmt->bindParam(':added', $_POST['added']);
$stmt->bindParam(':game', $_POST['game']);
$stmt->bindParam(':race', $_POST['race']);
$stmt->bindParam(':bih', $_POST['bih']);
$stmt->bindParam(':rule', $_POST['rule']);
$stmt->bindParam(':handicapped', $_POST['handicapped']);
$stmt->bindParam(':table_size', $_POST['table_size']);
$stmt->bindParam(':tables_used', $_POST['tables_used']);
$stmt->bindParam(':cueball', $_POST['cueball']);
$stmt->bindParam(':equipment', $_POST['equipment']);
$stmt->bindParam(':noise', $_POST['noise']);
$stmt->bindParam(':space', $_POST['space']);
$stmt->bindParam(':pots', $_POST['pots']);
$stmt->bindParam(':description', $_POST['description']);
$stmt->bindParam(':id', $id);

// Execute the query
if($stmt->execute()){
echo "<div class='alert alert-success'>";
echo "Record was updated.";
echo "</div>";
}else{
echo "<div class='alert alert-danger'>";
echo 'Unable to update record. Please try again.';
echo "</div>";
}
}

// values to fill up our form
$location_id = $_POST['location_id'];
$day = $_POST['day'];
$time = $_POST['time'];
$fee = $_POST['fee'];
$added = $_POST['added'];
$game = $_POST['game'];
$race = $_POST['race'];
$bih = $_POST['bih'];
$rule = $_POST['rule'];
$handicapped = $_POST['handicapped'];
$table_size = $_POST['table_size'];
$tables_used = $_POST['tables_used'];
$cueball = $_POST['cueball'];
$equipment = $_POST['equipment'];
$noise = $_POST['noise'];
$space = $_POST['space'];
$pots = $_POST['pots'];
$description = $_POST['description'];
}

// show errors, if any
catch(PDOException $exception){
die('ERROR: ' . $exception->getMessage());
}
}

else{
// read current record's data
try {

// prepare 'select' query
$query = "SELECT id, location_id, day, time, fee, added, game, bih, rule, handicapped, ";
$query .= "table_size, tables_used, cueball, equipment, noise, space, pots, description ";
$query .= "FROM tournaments WHERE id=? limit 0,1";
echo $query;
$stmt = $con->prepare( $query );

// this is the first question mark
$stmt->bindParam(1, $id);

// execute our query
$stmt->execute();

// store retrieved row to a variable
$row = $stmt->fetch(PDO::FETCH_ASSOC);

// values to fill up our form
$location_id = $_POST['location_id'];
$day = $_POST['day'];
$time = $_POST['time'];
$fee = $_POST['fee'];
$added = $_POST['added'];
$game = $_POST['game'];
$race = $_POST['race'];
$bih = $_POST['bih'];
$rule = $_POST['rule'];
$handicapped = $_POST['handicapped'];
$table_size = $_POST['table_size'];
$tables_used = $_POST['tables_used'];
$cueball = $_POST['cueball'];
$equipment = $_POST['equipment'];
$noise = $_POST['noise'];
$space = $_POST['space'];
$pots = $_POST['pots'];
$description = $_POST['description'];


}

// show error
catch(PDOException $exception){
die('ERROR: ' . $exception->getMessage());
}
}

?>
<!-- to go back to records list -->
<a href='read_tournaments.php' class='btn btn-primary pull-right margin-bottom-1em'>
<span class='glyphicon glyphicon-list'></span> Read Records
</a>

<!--we have our html form here where new user information will be entered-->
<form action='update_tournament.php?id=<?php echo $id; ?>' method='post' border='0'>
<table class='table table-bordered table-hover'>
<tr>
<td>Location</td>
<td>
<?php
// read the locations from the database

// select all categories
$query = "SELECT id, name FROM locations ORDER BY name";

// prepare query statement and execute
$stmt = $con->prepare( $query );
$stmt->execute();

// put them in a select drop-down
echo "<select data-placeholder=\"Choose a Location...\" class=\"chosen-select\" name='location_id' style=\"width: 300px\">\n";
echo "<option value=\"\"></option>\n";

while ($row_location = $stmt->fetch(PDO::FETCH_ASSOC)){
extract($row_location);

// auto select category of this record
echo $id==$location_id ? "<option value='{$id}' selected>" : "<option value='{$id}'>";
echo "{$name}";
echo "</option>\n";
}
echo "</select>";
?>
</td>
</tr>
<tr>
<td>Day</td>
<td>
<select data-placeholder="Please Choose Day..." class="chosen-select" name="day" style="width: 300px">
<option value=""></option>
<option value="Monday">Monday</option>
<option value="Tuesday">Tuesday</option>
<option value="Wednesday">Wednesday</option>
<option value="Thursday">Thursday</option>
<option value="Friday">Friday</option>
<option value="Saturday">Saturday</option>
<option value="Sunday">Sunday</option>
</select>
</td>
</tr>
<tr>
<td>Time</td>
<td>
<select data-placeholder="Please Choose Time..." class="chosen-select" name="time" style="width: 300px">
<option value=""></option>
<option value="12:00 AM">12:00 AM</option>
<option value="12:15 AM">12:15 AM</option>
<option value="12:30 AM">12:30 AM</option>
<option value="12:45 AM">12:45 AM</option>

<option value="1:00 AM">1:00 AM</option>
<option value="1:15 AM">1:15 AM</option>
<option value="1:30 AM">1:30 AM</option>
<option value="1:45 AM">1:45 AM</option>

<option value="2:00 AM">2:00 AM</option>
<option value="2:15 AM">2:15 AM</option>
<option value="2:30 AM">2:30 AM</option>
<option value="2:45 AM">2:45 AM</option>

<option value="3:00 AM">3:00 AM</option>
<option value="3:15 AM">3:15 AM</option>
<option value="3:30 AM">3:30 AM</option>
<option value="3:45 AM">3:45 AM</option>

<option value="4:00 AM">4:00 AM</option>
<option value="4:15 AM">4:15 AM</option>
<option value="4:30 AM">4:30 AM</option>
<option value="4:45 AM">4:45 AM</option>

<option value="5:00 AM">5:00 AM</option>
<option value="5:15 AM">5:15 AM</option>
<option value="5:30 AM">5:30 AM</option>
<option value="5:45 AM">5:45 AM</option>

<option value="6:00 AM">6:00 AM</option>
<option value="6:15 AM">6:15 AM</option>
<option value="6:30 AM">6:30 AM</option>
<option value="6:45 AM">6:45 AM</option>

<option value="7:00 AM">7:00 AM</option>
<option value="7:15 AM">7:15 AM</option>
<option value="7:30 AM">7:30 AM</option>
<option value="7:45 AM">7:45 AM</option>

<option value="8:00 AM">8:00 AM</option>
<option value="8:15 AM">8:15 AM</option>
<option value="8:30 AM">8:30 AM</option>
<option value="8:45 AM">8:45 AM</option>

<option value="9:00 AM">9:00 AM</option>
<option value="9:15 AM">9:15 AM</option>
<option value="9:30 AM">9:30 AM</option>
<option value="9:45 AM">9:45 AM</option>

<option value="10:00 AM">10:00 AM</option>
<option value="10:15 AM">10:15 AM</option>
<option value="10:30 AM">10:30 AM</option>
<option value="10:45 AM">10:45 AM</option>

<option value="11:00 AM">11:00 AM</option>
<option value="11:15 AM">11:15 AM</option>
<option value="11:30 AM">11:30 AM</option>
<option value="11:45 AM">11:45 AM</option>

<option value="12:00 PM">12:00 PM</option>
<option value="12:15 PM">12:15 PM</option>
<option value="12:30 PM">12:30 PM</option>
<option value="12:45 PM">12:45 PM</option>

<option value="1:00 PM">1:00 PM</option>
<option value="1:15 PM">1:15 PM</option>
<option value="1:30 PM">1:30 PM</option>
<option value="1:45 PM">1:45 PM</option>

<option value="2:00 PM">2:00 PM</option>
<option value="2:15 PM">2:15 PM</option>
<option value="2:30 PM">2:30 PM</option>
<option value="2:45 PM">2:45 PM</option>

<option value="3:00 PM">3:00 PM</option>
<option value="3:15 PM">3:15 PM</option>
<option value="3:30 PM">3:30 PM</option>
<option value="3:45 PM">3:45 PM</option>

<option value="4:00 PM">4:00 PM</option>
<option value="4:15 PM">4:15 PM</option>
<option value="4:30 PM">4:30 PM</option>
<option value="4:45 PM">4:45 PM</option>

<option value="5:00 PM">5:00 PM</option>
<option value="5:15 PM">5:15 PM</option>
<option value="5:30 PM">5:30 PM</option>
<option value="5:45 PM">5:45 PM</option>

<option value="6:00 PM">6:00 PM</option>
<option value="6:15 PM">6:15 PM</option>
<option value="6:30 PM">6:30 PM</option>
<option value="6:45 PM">6:45 PM</option>

<option value="7:00 PM">7:00 PM</option>
<option value="7:15 PM">7:15 PM</option>
<option value="7:30 PM">7:30 PM</option>
<option value="7:45 PM">7:45 PM</option>

<option value="8:00 PM">8:00 PM</option>
<option value="8:15 PM">8:15 PM</option>
<option value="8:30 PM">8:30 PM</option>
<option value="8:45 PM">8:45 PM</option>

<option value="9:00 PM">9:00 PM</option>
<option value="9:15 PM">9:15 PM</option>
<option value="9:30 PM">9:30 PM</option>
<option value="9:45 PM">9:45 PM</option>

<option value="10:00 PM">10:00 PM</option>
<option value="10:15 PM">10:15 PM</option>
<option value="10:30 PM">10:30 PM</option>
<option value="10:45 PM">10:45 PM</option>

<option value="11:00 PM">11:00 PM</option>
<option value="11:15 PM">11:15 PM</option>
<option value="11:30 PM">11:30 PM</option>
<option value="11:45 PM">11:45 PM</option>
</select>
</td>
</tr>
<tr>
<td>Fee:</td>
<td>
<select data-placeholder="Please Choose a Fee..." class="chosen-select" name="fee" style="width: 300px">
<option value=""></option>
<option value="Free">This is Free Tournament</option>
<option value="$5">5</option>
<option value="$6">6</option>
<option value="$7">7</option>
<option value="$8">8</option>
<option value="$9">9</option>
<option value="$10">10</option>
<option value="$11">11</option>
<option value="$12">12</option>
<option value="$13">13</option>
<option value="$14">14</option>
<option value="$15">15</option>
<option value="$16">16</option>
<option value="$17">17</option>
<option value="$18">18</option>
<option value="$19">19</option>
<option value="$20">20</option>
<option value="$25">25</option>
<option value="$30">20</option>
<option value="$35">35</option>
<option value="$40">40</option>
<option value="$45">45</option>
<option value="$50">50</option>
<option value="$55">55</option>
<option value="$60">60</option>
<option value="$65">65</option>
<option value="$70">70</option>
<option value="$75">75</option>
<option value="$80">80</option>
<option value="$85">85</option>
<option value="$90">90</option>
<option value="$95">95</option>
<option value="$100">100</option>
<option value="$105">105</option>
<option value="$110">110</option>
<option value="$115">115</option>
<option value="$120">120</option>
<option value="$125">125</option>
<option value="$130">130</option>
<option value="$135">135</option>
<option value="$140">140</option>
<option value="$145">145</option>
<option value="$150">150</option>
<option value="$155">155</option>
<option value="$160">160</option>
<option value="$165">165</option>
<option value="$170">170</option>
<option value="$175">175</option>
<option value="$180">180</option>
<option value="$185">185</option>
<option value="$190">190</option>
<option value="$195">195</option>
<option value="$200">200</option>
</select>
</td>
</tr>
<tr>
<td>Added:</td>
<td>
<select data-placeholder="Is Money Added?" class="chosen-select" name="added" style="width: 300px">
<option value=""></option>
<option value=""></option>
<option value="No">No Money is Added</option>
<option value="Yes">Yes, Money is Added</option>
</select>
</td>
</tr>
<tr>

<tr>
<td>Game:</td>
<td>
<select data-placeholder="Please Choose a Game..." class="chosen-select" name="game" style="width: 300px">
<option value=""></option>
<option value=""></option>
<option value="8-Ball">8-Ball</option>
<option value="9-Ball">9-Ball</option>
<option value="10-Ball">10-Ball</option>
<option value="1-Pocket">1-Pocket</option>
<option value="Other Game">Other Game</option>
</select>
</td>
</tr>
<tr>
<td>Side Pots:</td>
<td>
<select data-placeholder="Is There a Side Pot?" class="chosen-select" name="pots" style="width: 300px">
<option value=""></option>
<option value="10 Ball Pot">10 Ball Tickets</option>
<option value="Break Pot">Break Pot</option>
<option value="No Side Pot">No Side Pot</option>
</select>
</td>
</tr>
<tr>
<td>Race:</td>
<td>
<select data-placeholder="What is the Race?" class="chosen-select" name="race" style="width: 300px">
<option value=""></option>
<option value="1 Game">1 Game</option>
<option value="Race to 2">Race to 2</option>
<option value="Race to 3">Race to 3</option>
<option value="Race to 4">Race to 4</option>
<option value="Race to 5">Race to 5</option>
<option value="Race to 6">Race to 6</option>
<option value="Race to 7">Race to 7</option>
<option value="Race to 8">Race to 8</option>
<option value="Race to 9">Race to 9</option>
<option value="Race to 10">Race to 10</option>
<option value="Race to 11">Race to 11</option>
<option value="Race to 12">Race to 12</option>
</select>
</td>
</tr>
<tr>
<td>Ball In Hand:</td>
<td>
<select data-placeholder="Is there Ball In Hand?" class="chosen-select" name="bih" style="width: 300px">
<option value=""></option>
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>
</td>
</tr>
<tr>
<td>Rule:</td>
<td>
<select data-placeholder="What are the Rules?" class="chosen-select" name="rule" style="width: 300px">
<option value=""></option>
<option value="Call Pocket">Call Pocket</option>
<option value="Call Shot">Call Shot</option>
<option value="Any Pocket">Any Pocket</option>
</select>
</td>
</tr>
<tr>
<td>Handicapped:</td>
<td>
<select data-placeholder="Handicapped?" class="chosen-select" name="handicapped" style="width: 300px">
<option value=""></option>
<option value="No">No</option>
<option value="Yes">Yes</option>
</select>
</td>
</tr>
<tr>
<td>Table Size:</td>
<td>
<select data-placeholder="Size of the Tables:" class="chosen-select" name="table_size" style="width: 300px">
<option value=""></option>
<option value="7 Ft.">7 Ft.</option>
<option value="9 Ft.">9 Ft.</option>
<option value="Billiard">Billiard</option>
<option value="Snooker">Snooker</option>
</select>
</td>
</tr>
<tr>
<td>Tables In Use:</td>
<td>
<select data-placeholder="Number of Tables in Use:" class="chosen-select" name="tables_used" style="width: 300px">
<option value=""></option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
</select>
</td>
</tr>
<tr>
<td>Cueball Size:</td>
<td>
<select data-placeholder="Cueball Size:" class="chosen-select" name="cueball" style="width: 300px">
<option value=""></option>
<option value="small">small</option>
<option value="large">large</option>
</select>
</td>
</tr>
<tr>
<td>Equipment:</td>
<td>
<select data-placeholder="Rate the Equipment:" class="chosen-select" name="equipment" style="width: 300px">
<option value=""></option>
<option value="Excellent">Excellent</option>
<option value="Good">Good</option>
<option value="Poor">Poor</option>
</select>
</td>
</tr>
<tr>
<td>Noise Level:</td>
<td>
<select data-placeholder="Rate Noise Level:" class="chosen-select" name="noise" style="width: 300px">
<option value=""></option>
<option value="Quiet">Quiet</option>
<option value="Moderate">Moderate</option>
<option value="Loud">Loud</option>
</select>
</td>
</tr>
<tr>
<td>Space to Play:</td>
<td>
<select data-placeholder="Rate Space to play:" class="chosen-select" name="space" style="width: 300px">
<option value=""></option>
<option value="Excellent">Excellent</option>
<option value="Good">Good</option>
<option value="Poor">Poor</option>
</select>
</td>
</tr>
<tr>
<td>Description:</td>
<td><textarea type='text' name='description' class='form-control' required><?php echo isset($_POST['description']) ? htmlspecialchars($_POST['description'], ENT_QUOTES) : ""; ?></textarea></td>
</tr>
<tr>
<td></td>
<td>
<input type='submit' value='Save Changes' class='btn btn-primary' />
</td>
</tr>
</table>
</form>

<?php
// page footer
include_once "layout_foot.php";
?>


My Database table:

-- phpMyAdmin SQL Dump
-- version 4.2.7.1
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Nov 09, 2015 at 04:22 AM
-- Server version: 5.6.20
-- PHP Version: 5.5.15

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;

--
-- Database: `ptms`
--

-- --------------------------------------------------------

--
-- Table structure for table `tournaments`
--

CREATE TABLE IF NOT EXISTS `tournaments` (
`id` int(11) NOT NULL,
`location_id` int(11) NOT NULL,
`day` varchar(20) NOT NULL,
`time` varchar(30) NOT NULL,
`fee` varchar(30) NOT NULL,
`added` varchar(30) NOT NULL,
`game` varchar(20) NOT NULL,
`race` varchar(30) NOT NULL,
`rule` varchar(20) NOT NULL,
`bih` varchar(30) NOT NULL,
`handicapped` varchar(20) NOT NULL,
`table_size` varchar(30) NOT NULL,
`tables_used` varchar(30) NOT NULL,
`cueball` varchar(20) NOT NULL,
`equipment` varchar(20) NOT NULL,
`noise` varchar(20) NOT NULL,
`space` varchar(20) NOT NULL,
`pots` varchar(30) NOT NULL,
`description` text NOT NULL,
`created` datetime NOT NULL,
`modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=9 ;

--
-- Dumping data for table `tournaments`
--

INSERT INTO `tournaments` (`id`, `location_id`, `day`, `time`, `fee`, `added`, `game`, `race`, `rule`, `bih`, `handicapped`, `table_size`, `tables_used`, `cueball`, `equipment`, `noise`, `space`, `pots`, `description`, `created`, `modified`) VALUES
(8, 7, 'Tuesday', '12:15 AM', '$5', 'Yes', '8-Ball', 'Race to 2', 'Call Shot', 'Yes', 'No', '7 Ft.', '3', 'small', 'Excellent', 'Quiet', 'Excellent', '10 Ball Pot', 'rt', '2015-11-08 16:30:29', '2015-11-09 02:47:49');

--
-- Indexes for dumped tables
--

--
-- Indexes for table `tournaments`
--
ALTER TABLE `tournaments`
ADD PRIMARY KEY (`id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `tournaments`
--
ALTER TABLE `tournaments`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=9;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

Answer
if($_POST){

}else{
    // read current record's data
    try {

        ....

        // values to fill up our form
        $location_id = $_POST['location_id'];
        $day = $_POST['day'];
        $time = $_POST['time']; 
        $fee = $_POST['fee']; 
        $added = $_POST['added']; 
        $game = $_POST['game']; 
        $race = $_POST['race'];
        $bih = $_POST['bih']; 
        $rule = $_POST['rule']; 
        $handicapped = $_POST['handicapped'];
        $table_size = $_POST['table_size']; 
        $tables_used = $_POST['tables_used']; 
        $cueball = $_POST['cueball'];
        $equipment = $_POST['equipment']; 
        $noise = $_POST['noise']; 
        $space = $_POST['space']; 
        $pots = $_POST['pots']; 
        $description = $_POST['description']; 


    }catch(PDOException $exception){
        die('ERROR: ' . $exception->getMessage());
    }
}

$_POST is not set on those lines. On lines 183..200 $_POST doesn’t contains array index "day" , "location" etc ... I'm not sure but I think that you need to use $row instead of $_POST

else{
    // read current record's data
    try {

        // prepare 'select' query
        $query = "SELECT id, location_id, day, time, fee, added, game, bih, rule, handicapped, ";
        $query .= "table_size, tables_used, cueball, equipment, noise, space, pots, description ";
        $query .= "FROM tournaments WHERE id=? limit 0,1";
        echo $query;
        $stmt = $con->prepare( $query );

        // this is the first question mark
        $stmt->bindParam(1, $id);

        // execute our query
        $stmt->execute();

        // store retrieved row to a variable
        $row = $stmt->fetch(PDO::FETCH_ASSOC);

        // values to fill up our form
        $location_id = $row['location_id'];
        $day = $row['day'];
        $time = $row['time']; 
        $fee = $row['fee']; 
        $added = $row['added']; 
        $game = $row['game']; 
        $race = $row['race'];
        $bih = $row['bih']; 
        $rule = $row['rule']; 
        $handicapped = $row['handicapped'];
        $table_size = $row['table_size']; 
        $tables_used = $row['tables_used']; 
        $cueball = $row['cueball'];
        $equipment = $row['equipment']; 
        $noise = $row['noise']; 
        $space = $row['space']; 
        $pots = $row['pots']; 
        $description = $row['description']; 


    }

    // show error
    catch(PDOException $exception){
        die('ERROR: ' . $exception->getMessage());
    }
}