PHP / MySQL Insert

When I click submit on this form the data is not making it into the table. Any help would be appreciated. Please let me know if there is more information that would help.

Thank You

Form------------------------------------------>
<form action="insertevent.php" method="post">

<table border="1" cellspacing="0" cellpadding="0" align="center">

     <tr>
       <td>No Points Awarded:</td>
       <td>Date:</td>
       <td>Place:</td>
       <td>Start Time:</td>
       <td>Notes:</td>
       <td>Special Event:</td>
       </tr>
       <tr>
       <td><input type="checkbox" name="Points_Awarded" value="*"/></td>
     <td><input type="text" name="Date" /></td>
     <td><input type="text" name="Place" /></td>
     <td><input type="text" name="StartTime" /></td>
     <td><input type="text" name="Notes" /></td>
     <td><input type="text" name="Event" /></td>
       </tr>

<tr>
<td colspan="6" align="center"><input type="submit" name="submit" value="Add Event" /></td>
</tr>
</table>
</form>




insertevent.php---------------------------->
<?php
mysql_connect("mysql", "******", "******") or die ('Could not connect: ' . mysql_error());
mysql_select_db("RMDCRA");

$Points_Awarded = $_POST['Points_Awarded'];
$Date=$_POST['Date'];
$Place=$_POST['Place'];
$StartTime=$_POST['StartTime'];
$Notes=$_POST['Notes'];
$Event=$_POST['Event'];

$sql = mysql_query("INSERT INTO Schedule (`Race_Number`, `Points_Awarded`, `Date`, `Place`, `StartTime`, `Notes`, `Event`)
    VALUES (NULL, '$Points_Awarded', '$Date', '$Place', '$StartTime', '$Notes', '$Event', '$Phone')") or die(mysql_error());
header('Location: http://rmdcra.org/admin/Admin.php');
?>

patrickm12981Asked:
Who is Participating?
 
Mark BradyConnect With a Mentor Principal Data EngineerCommented:
A blank page means the script is halting and the page will not excecute any more code so it stays blank. The first problem I see here is you are trying to insert a value into a field set as "auto increment". Even if that value is empty you need to remove it from your code. The value is `Race_Number` and NULL. Because that column is set to AI you can leave it out of your query altogether. Also, you don't need the backtics unless your column name has a space in between two words. Remove the brackets from your $sql variable so change the query from :

$sql = ("INSERT INTO `RMDCRA`.`Schedule` (`Race_Number`, `Points_Awarded`, `Date`, `Place`, `StartTime`, `Notes`, `Event`)
    VALUES (NULL, '$Points_Awarded', '$Date', '$Place', '$StartTime', '$Notes', '$Event')") or die(mysql_error());

To this:

$sql = "INSERT INTO `RMDCRA`.`Schedule` (Points_Awarded, Date, Place, StartTime, Notes, Event)
 VALUES ('$Points_Awarded', '$Date', '$Place', '$StartTime', '$Notes', '$Event')";

// Now run the query
$result = mysql_query($sql)or die(mysql_error());
if($result){
echo "The query worked!";
}else{
echo "The query failed!!!";
}
0
 
cyberstalkerConnect With a Mentor Commented:
The number of columns does not match. Remove the '$Phone' part from the values list.
0
 
patrickm12981Author Commented:
Thanks for that - still not working...

<?php
mysql_connect("mysql", "******", "******") or die ('Could not connect: ' . mysql_error());
mysql_select_db("RMDCRA");

$Points_Awarded = $_POST['Points_Awarded'];
$Date=$_POST['Date'];
$Place=$_POST['Place'];
$StartTime=$_POST['StartTime'];
$Notes=$_POST['Notes'];
$Event=$_POST['Event'];

$sql = mysql_query("INSERT INTO Schedule (`Race_Number`, `Points_Awarded`, `Date`, `Place`, `StartTime`, `Notes`, `Event`)
    VALUES (NULL, '$Points_Awarded', '$Date', '$Place', '$StartTime', '$Notes', '$Event')") or die(mysql_error());
header('Location: http://rmdcra.org/admin/Admin.php');
?>
0
Improve Your Query Performance Tuning

In this FREE six-day email course, you'll learn from Janis Griffin, Database Performance Evangelist. She'll teach 12 steps that you can use to optimize your queries as much as possible and see measurable results in your work. Get started today!

 
cyberstalkerCommented:
What error are you getting? I do not see any other errors, besides the obvious sql injection dangers.

Try running the query manually to see what happens.
0
 
rationalbossConnect With a Mentor Commented:

<?php
mysql_connect("mysql", "******", "******") or die ('Could not connect: ' . mysql_error());
mysql_select_db("RMDCRA");

$Points_Awarded = $_POST['Points_Awarded'];
$Date=$_POST['Date'];
$Place=$_POST['Place'];
$StartTime=$_POST['StartTime'];
$Notes=$_POST['Notes'];
$Event=$_POST['Event'];

$sql = ("INSERT INTO Schedule (`Race_Number`, `Points_Awarded`, `Date`, `Place`, `StartTime`, `Notes`, `Event`)
    VALUES (NULL, '$Points_Awarded', '$Date', '$Place', '$StartTime', '$Notes', '$Event')");
echo $sql;
// or die(mysql_error());
//header('Location: http://rmdcra.org/admin/Admin.php');
?>

Open in new window

What is the output?
0
 
patrickm12981Author Commented:
Nothing was returned from the "echo $sql" it went back to the form page, no errors.
0
 
rationalbossCommented:
That's odd, did you comment the redirection?
echo $sql should contain: INSERT INTO Schedule ....
0
 
patrickm12981Author Commented:
I copied and pasted exactly what you wrote....-> Here is the entire insertevent.php


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<title>insertevent.php</title>
</head>
<body>

<?php
<?php
mysql_connect("mysql", "****", "*****") or die ('Could not connect: ' . mysql_error());
mysql_select_db("RMDCRA");

$Points_Awarded = $_POST['Points_Awarded'];
$Date=$_POST['Date'];
$Place=$_POST['Place'];
$StartTime=$_POST['StartTime'];
$Notes=$_POST['Notes'];
$Event=$_POST['Event'];

$sql = ("INSERT INTO Schedule (`Race_Number`, `Points_Awarded`, `Date`, `Place`, `StartTime`, `Notes`, `Event`)
    VALUES (NULL, '$Points_Awarded', '$Date', '$Place', '$StartTime', '$Notes', '$Event')");
echo $sql;
// or die(mysql_error());
//header('Location: http://rmdcra.org/admin/Admin.php');
?> 

</body>
</html>

<!--
For Reference:
INSERT INTO `RMDCRA`.`Schedule` (
`Race_Number` ,
`PointsAwarded` ,
`Date` ,
`Place` ,
`StartTime` ,
`Notes` ,
`Event` 
)
VALUES (
NULL , '*', '2011-04-03', 'I-76 Speedway', NULL , NULL , 'Hot Laps'
);

-->

Open in new window

0
 
patrickm12981Author Commented:
Here is the entire forms page - Admin.php


<?php

// Inialize session
session_start();

// Check, if username session is NOT set then this page will jump to login page
if (!isset($_SESSION['username'])) {
header('Location: index.php');
}

?>

<?php

error_reporting(E_ALL);
include("../includes/Header.html");
include("../includes/conn.php"); 
?>
<center><p><a href="logout.php">Logout</a></p></center>
<table width="930" align="center">
<tr>
<td valign="top">

<center><h2><u>Submit Daily Points Totals</u></h2></center>

<form action="insert.php" method="post">

<table border="1" cellspacing="0" cellpadding="0" align="center">
	<tr>
		<th>
		Race Date:
		</th>
		<td colspan="2">
		<?php
		$query="SELECT Race_Number, Date FROM Schedule WHERE PointsAwarded NOT LIKE '*' ORDER BY Date";
		$result2 = mysql_query($query) or die("Error executing:<br>$query<br>" . mysql_error() );

		echo "<select name=\"Race_Number\">";
		echo "<option></option>";
		while ($row=mysql_fetch_assoc($result2)) {
		echo "<option value=\"{$row['Race_Number']}\">{$row['Date']}</option>";
		}
		echo "</select>";
		?>
		</td>
	<tr>
		<th>Car Number</th>
		<th>Points</th>
	</tr>
<?php	
$sql = "SELECT Roster_Number, Car_Number FROM Roster";
$result = mysql_query($sql) or trigger_error(mysql_error(),E_USER_ERROR);

while(list($Roster_Number, $Car_Number)=mysql_fetch_row($result)){

echo '<tr><td>'.$Car_Number.'</td><td><input style="border: 1px solid #FFFFFF" type="text" name ="pointsarray['.$Roster_Number.']"/></td></tr>'."\n";
}
?>
<tr>
<td colspan="3" align="center"><input type="submit" name="submit" value="Submit Points" /></td>
</tr>
</table>
</form>
</td>
<td valign="top">

<center><h2><u>Edit Points</u></h2></center>

<form action="updatepoints.php" method="post">


<table border="1" cellspacing="0" cellpadding="0" align="center">
	<tr>
		<th>
		Race Date:
		</th>
		<td colspan="2">
		<?php
		$query="SELECT Race_Number, Date FROM Schedule WHERE PointsAwarded NOT LIKE '*' ORDER BY Date";
		$result2 = mysql_query($query) or die("Error executing:<br>$query<br>" . mysql_error() );

		echo "<select name=\"Race_Number\">";
		echo "<option></option>";
		while ($row=mysql_fetch_assoc($result2)) {
		echo "<option value=\"{$row['Race_Number']}\">{$row['Date']}</option>";
		}
		echo "</select>";
		?>
		</td>
	<tr>
		<th>Car Number</th>
		<th>Points</th>
	</tr>
<?php
$sql = "SELECT Roster_Number, Car_Number FROM Roster";
$result = mysql_query($sql) or trigger_error(mysql_error(),E_USER_ERROR);

while(list($Roster_Number, $Car_Number)=mysql_fetch_row($result)){

echo '<tr><td>'.$Car_Number.'</td><td><input style="border: 1px solid #FFFFFF" type="text" name ="pointsarray['.$Roster_Number.']"/></td></tr>'."\n";
}
?>
<tr>
<td colspan="3" align="center"><input type="submit" name="submit" value="Edit Points" /></td>
</tr>
</table>
</form>
</td>
<tr>
    
<td valign="top">
<center><h2><u>Submit Race Results</u></h2></center>

<form action="insertresults.php" method="post">
<?php
if($updated===TRUE)
	{echo '<div>Results Updated</div>';
	}
?>
<table border="1" cellspacing="0" cellpadding="0" align="center">
	<tr>
		<th>
			Race Date:
		</th>
		
		<td colspan="2">
			<?php
			$query2="SELECT Race_Number, Date FROM Schedule ORDER BY Date";
			$result3 = mysql_query($query2) or die("Error executing:<br>$query2<br>" . mysql_error() );

			echo "<select name=\"Race_Number\">";
			echo "<option></option>";
			while ($row=mysql_fetch_assoc($result3)) {
			echo "<option value=\"{$row['Race_Number']}\">{$row['Date']}</option>";
			}
			echo "</select>";
			?>
		</td>	
	</tr>
	
	<tr>
		<th>
			Event:
		</th>
		
		<td colspan="2">
			<?php
			$query3="SELECT Event FROM Events";
			$result4 = mysql_query($query3) or die("Error executing:<br>$query3<br>" . mysql_error() );

			echo "<select name=\"Event\">";
			echo "<option></option>";
			while ($row=mysql_fetch_assoc($result4)) {
			echo "<option>".$row['Event']."</option>";
			}
			echo "</select>";
			?>
		</td>
	</tr>
        
            <tr><td>1</td><td><input type="text" name="1" /></td></tr>
            <tr><td>2</td><td><input type="text" name="2" /></td></tr>
            <tr><td>3</td><td><input type="text" name="3" /></td></tr>
            <tr><td>4</td><td><input type="text" name="4" /></td></tr>
            <tr><td>5</td><td><input type="text" name="5" /></td></tr>
            <tr><td>6</td><td><input type="text" name="6" /></td></tr>
            <tr><td>7</td><td><input type="text" name="7" /></td></tr>
            <tr><td>8</td><td><input type="text" name="8" /></td></tr>
            <tr><td>9</td><td><input type="text" name="9" /></td></tr>
            <tr><td>10</td><td><input type="text" name="10" /></td></tr>
            <tr><td>11</td><td><input type="text" name="11" /></td></tr>
            <tr><td>12</td><td><input type="text" name="12" /></td></tr>
            <tr><td>13</td><td><input type="text" name="13" /></td></tr>
            <tr><td>14</td><td><input type="text" name="14" /></td></tr>
            <tr><td>15</td><td><input type="text" name="15" /></td></tr>
            <tr><td>16</td><td><input type="text" name="16" /></td></tr>
            <tr><td>17</td><td><input type="text" name="17" /></td></tr>
            <tr><td>18</td><td><input type="text" name="18" /></td></tr>
            <tr><td>19</td><td><input type="text" name="19" /></td></tr>
            <tr><td>20</td><td><input type="text" name="20" /></td></tr>
            <tr><td>21</td><td><input type="text" name="21" /></td></tr>
            <tr><td>22</td><td><input type="text" name="22" /></td></tr>
            <tr><td>23</td><td><input type="text" name="23" /></td></tr>
            <tr><td>24</td><td><input type="text" name="24" /></td></tr>
            <tr><td>25</td><td><input type="text" name="25" /></td></tr>
            <tr><td>26</td><td><input type="text" name="26" /></td></tr>
            <tr><td>27</td><td><input type="text" name="27" /></td></tr>
            <tr><td>28</td><td><input type="text" name="28" /></td></tr>
            <tr><td>29</td><td><input type="text" name="29" /></td></tr>
            <tr> <td>30</td><td><input type="text" name="30" /></td></tr>
            <tr><td>DNF1</td><td><input type="text" name="DNF1" /></td></tr>
            <tr><td>DNF2</td><td><input type="text" name="DNF2" /></td></tr>
            <tr><td>DNF3</td><td><input type="text" name="DNF3" /></td></tr>
            <tr><td>DNF4</td><td><input type="text" name="DNF4" /></td></tr>
            <tr><td>DNF5</td><td><input type="text" name="DNF5" /></td></tr>
            <tr><td>DNF6</td><td><input type="text" name="DNF6" /></td></tr>
            <tr><td>DNF7</td><td><input type="text" name="DNF7" /></td></tr>
            <tr><td>DNF8</td><td><input type="text" name="DNF8" /></td></tr>
            <tr><td>DNF9</td><td><input type="text" name="DNF9" /></td></tr>
            <tr><td>DNF10</td><td><input type="text" name="DNF10" /></td></tr>
            <tr><td>DNS1</td><td><input type="text" name="DNS1" /></td></tr>
            <tr><td>DNS2</td><td><input type="text" name="DNS2" /></td></tr>
            <tr><td>DNS3</td><td><input type="text" name="DNS3" /></td></tr>
            <tr><td>DNS4</td><td><input type="text" name="DNS4" /></td></tr>
            <tr><td>DNS5</td><td><input type="text" name="DNS5" /></td></tr>
            <tr><td>NT1</td><td><input type="text" name="NT1" /></td></tr>
            <tr><td>NT2</td><td><input type="text" name="NT2" /></td></tr>
            <tr><td>NT3</td><td><input type="text" name="NT3" /></td></tr>
            <tr><td>NT4</td><td><input type="text" name="NT4" /></td></tr>
            <tr><td>NT5</td><td><input type="text" name="NT5" /></td></tr>
<tr>
<td colspan="3" align="center"><input type="submit" name="submit" value="Submit Results" /></td>
</tr>
</table>
</form>
</td>
<td valign="top">
<center><h2><u>Edit Race Results</u></h2></center>

<form action="updateresults.php" method="post">

<table border="1" cellspacing="0" cellpadding="0" align="center">
	<tr>
		<th>
			Race Date:
		</th>

		<td colspan="2">
			<?php
			$query2="SELECT Race_Number, Date FROM Schedule ORDER BY Date";
			$result3 = mysql_query($query2) or die("Error executing:<br>$query2<br>" . mysql_error() );

			echo "<select name=\"Race_Number\">";
			echo "<option></option>";
			while ($row=mysql_fetch_assoc($result3)) {
			echo "<option value=\"{$row['Race_Number']}\">{$row['Date']}</option>";
			}
			echo "</select>";
			?>
		</td>
	</tr>

	<tr>
		<th>
			Event:
		</th>

		<td colspan="2">
			<?php
			$query3="SELECT Event FROM Events";
			$result4 = mysql_query($query3) or die("Error executing:<br>$query3<br>" . mysql_error() );

			echo "<select name=\"Event\">";
			echo "<option></option>";
			while ($row=mysql_fetch_assoc($result4)) {
			echo "<option>".$row['Event']."</option>";
			}
			echo "</select>";
			?>
		</td>
	</tr>

            <tr><td>1</td><td><input type="text" name="1" /></td></tr>
            <tr><td>2</td><td><input type="text" name="2" /></td></tr>
            <tr><td>3</td><td><input type="text" name="3" /></td></tr>
            <tr><td>4</td><td><input type="text" name="4" /></td></tr>
            <tr><td>5</td><td><input type="text" name="5" /></td></tr>
            <tr><td>6</td><td><input type="text" name="6" /></td></tr>
            <tr><td>7</td><td><input type="text" name="7" /></td></tr>
            <tr><td>8</td><td><input type="text" name="8" /></td></tr>
            <tr><td>9</td><td><input type="text" name="9" /></td></tr>
            <tr><td>10</td><td><input type="text" name="10" /></td></tr>
            <tr><td>11</td><td><input type="text" name="11" /></td></tr>
            <tr><td>12</td><td><input type="text" name="12" /></td></tr>
            <tr><td>13</td><td><input type="text" name="13" /></td></tr>
            <tr><td>14</td><td><input type="text" name="14" /></td></tr>
            <tr><td>15</td><td><input type="text" name="15" /></td></tr>
            <tr><td>16</td><td><input type="text" name="16" /></td></tr>
            <tr><td>17</td><td><input type="text" name="17" /></td></tr>
            <tr><td>18</td><td><input type="text" name="18" /></td></tr>
            <tr><td>19</td><td><input type="text" name="19" /></td></tr>
            <tr><td>20</td><td><input type="text" name="20" /></td></tr>
            <tr><td>21</td><td><input type="text" name="21" /></td></tr>
            <tr><td>22</td><td><input type="text" name="22" /></td></tr>
            <tr><td>23</td><td><input type="text" name="23" /></td></tr>
            <tr><td>24</td><td><input type="text" name="24" /></td></tr>
            <tr><td>25</td><td><input type="text" name="25" /></td></tr>
            <tr><td>26</td><td><input type="text" name="26" /></td></tr>
            <tr><td>27</td><td><input type="text" name="27" /></td></tr>
            <tr><td>28</td><td><input type="text" name="28" /></td></tr>
            <tr><td>29</td><td><input type="text" name="29" /></td></tr>
            <tr> <td>30</td><td><input type="text" name="30" /></td></tr>
            <tr><td>DNF1</td><td><input type="text" name="DNF1" /></td></tr>
            <tr><td>DNF2</td><td><input type="text" name="DNF2" /></td></tr>
            <tr><td>DNF3</td><td><input type="text" name="DNF3" /></td></tr>
            <tr><td>DNF4</td><td><input type="text" name="DNF4" /></td></tr>
            <tr><td>DNF5</td><td><input type="text" name="DNF5" /></td></tr>
            <tr><td>DNF6</td><td><input type="text" name="DNF6" /></td></tr>
            <tr><td>DNF7</td><td><input type="text" name="DNF7" /></td></tr>
            <tr><td>DNF8</td><td><input type="text" name="DNF8" /></td></tr>
            <tr><td>DNF9</td><td><input type="text" name="DNF9" /></td></tr>
            <tr><td>DNF10</td><td><input type="text" name="DNF10" /></td></tr>
            <tr><td>DNS1</td><td><input type="text" name="DNS1" /></td></tr>
            <tr><td>DNS2</td><td><input type="text" name="DNS2" /></td></tr>
            <tr><td>DNS3</td><td><input type="text" name="DNS3" /></td></tr>
            <tr><td>DNS4</td><td><input type="text" name="DNS4" /></td></tr>
            <tr><td>DNS5</td><td><input type="text" name="DNS5" /></td></tr>
            <tr><td>NT1</td><td><input type="text" name="NT1" /></td></tr>
            <tr><td>NT2</td><td><input type="text" name="NT2" /></td></tr>
            <tr><td>NT3</td><td><input type="text" name="NT3" /></td></tr>
            <tr><td>NT4</td><td><input type="text" name="NT4" /></td></tr>
            <tr><td>NT5</td><td><input type="text" name="NT5" /></td></tr>

<tr>
<td colspan="3" align="center"><input type="submit" name="submit" value="Edit Results" /></td>
</tr>
</table>
</form>
</td>
</tr>

<tr>
<td>
<center><h2><u>Add Member to Roster</u></h2></center>
<form action="insertroster.php" method="post" enctype="multipart/form-data">

<table border="1" cellspacing="0" cellpadding="0" align="center">

     <tr><td>Car Number</td><td><input type="text" name="Car_Number" /></td></tr>
     <tr><td>Full Name</td><td><input type="text" name="Driver_Name" /></td></tr>
     <tr><td>Home Town</td><td><input type="text" name="Home_Town" /></td></tr>
     <tr><td>Cartoon Character</td><td><input type="text" name="Cartoon_Character" /></td></tr>
     <tr><td>Highlights</td><td><input type="text" name="Highlights" /></td></tr>
     <tr><td>Email</td><td><input type="text" name="Email" /></td></tr>
     <tr><td>Phone</td><td><input type="text" name="Phone" /></td></tr>
     <tr><td>Image</td><td><input type="file" name="mailfile" /></td></tr>

<tr>
<td colspan="3" align="center"><input type="submit" name="submit" value="Add Member" /></td>
</tr>
</table>
</form>
</td>
<td>
<center><h2><u>Edit Roster Member</u></h2></center>
<form action="updateroster.php" method="post" enctype="multipart/form-data">

<table border="1" cellspacing="0" cellpadding="0" align="center">

     <tr>
         <td>
            Car Number:
	</td>

	<td>
            <?php
            $query3="SELECT Car_Number FROM Roster";
            $result5 = mysql_query($query3) or die("Error executing:<br>$query4<br>" . mysql_error() );
            echo "<select name=\"Car_Number\">";
            echo "<option></option>";
            while ($row=mysql_fetch_assoc($result5)) {
            echo "<option>".$row['Car_Number']."</option>";
            }
            echo "</select>";
            ?>
	</td>
     </tr>
     <tr><td>Full Name</td><td><input type="text" name="Driver_Name" /></td></tr>
     <tr><td>Home Town</td><td><input type="text" name="Home_Town" /></td></tr>
     <tr><td>Cartoon Character</td><td><input type="text" name="Cartoon_Character" /></td></tr>
     <tr><td>Highlights</td><td><input type="text" name="Highlights" /></td></tr>
     <tr><td>Email</td><td><input type="text" name="Email" /></td></tr>
     <tr><td>Phone</td><td><input type="text" name="Phone" /></td></tr>
     <tr><td>Image</td><td><input type="file" name="mailfile" /></td></tr>

<tr>
<td colspan="3" align="center"><input type="submit" name="submit" value="Update Member" /></td>
</tr>
</table>
<tr>
<center>
<table>
<td>
<center><h2><u>Delete Roster Member</u></h2></center>
<form action="deleteroster.php" method="post"/>

<table border="1" cellspacing="0" cellpadding="0" align="center">

     <tr>
         <td>
            Car Number:
	</td>

	<td>
            <?php
            $query4="SELECT Car_Number FROM Roster";
            $result6 = mysql_query($query3) or die("Error executing:<br>$query4<br>" . mysql_error() );
            echo "<select name=\"Car_Number\">";
            echo "<option></option>";
            while ($row=mysql_fetch_assoc($result6)) {
            echo "<option>".$row['Car_Number']."</option>";
            }
            echo "</select>";
            ?>
	</td>
     </tr>

<tr>
<td colspan="3" align="center"><input type="submit" name="submit" value="Delete Member" /></td>
</tr>
</table>
</table>

<center><h2><u>Add Event</u></h2></center>
<form action="insertevent.php" method="post">

<table border="1" cellspacing="0" cellpadding="0" align="center">
     <tr>
	 <td>No Points Awarded:</td>
	 <td>Date:</td>
	 <td>Place:</td>
	 <td>Start Time:</td>
	 <td>Notes:</td>
	 <td>Special Event:</td>
	 </tr>
	 <tr>
	 <td><input type="checkbox" name="Points_Awarded" value="*"/></td>
     <td><input type="text" name="Date" /></td>
     <td><input type="text" name="Place" /></td>
     <td><input type="text" name="StartTime" /></td>
     <td><input type="text" name="Notes" /></td>
     <td><input type="text" name="Event" /></td>
	 </tr>

<tr>
<td colspan="6" align="center"><input type="submit" name="submit" value="Add Event" /></td>
</tr>
</table>
</form>
</center>
</form>
</td>
</tr>
</table>
</body>
</html>

Open in new window

0
 
Mark BradyPrincipal Data EngineerCommented:
Try removing the quotes from around the values as they look like the columns should/would be int values NOT vchar.

Please change your php script to include mysql_real_escape_string() on ALL posted values.

$Points_Awarded = mysql_real_escape_string($_POST['Points_Awarded']);
$Date = mysql_real_escape_string($_POST['Date']);
$Place = mysql_real_escape_string($_POST['Place']);

etc....etc.... that makes if safer !
0
 
patrickm12981Author Commented:
i sepreated out the form from the rest to its own page called admintest.php, also here my current insertevent.php. I not sure which quotes you sre talking about.

Also the table structure.


<?php

// Inialize session
session_start();

// Check, if username session is NOT set then this page will jump to login page
if (!isset($_SESSION['username'])) {
header('Location: index.php');
}

?>

<?php
error_reporting(E_ALL);
include("../includes/Header.html");
include("../includes/conn.php"); 
?>
<center><p><a href="logout.php">Logout</a></p></center>

<table width="930" align="center">
<tr>
<td valign="top">

<center><h2><u>Add Event</u></h2></center>
<form action="insertevent.php" method="post">

<table border="1" cellspacing="0" cellpadding="0" align="center">
     <tr>
	 <td>No Points Awarded:</td>
	 <td>Date:</td>
	 <td>Place:</td>
	 <td>Start Time:</td>
	 <td>Notes:</td>
	 <td>Special Event:</td>
	 </tr>
	 <tr>
	 <td><input type="checkbox" name="Points_Awarded" value="*"/></td>
     <td><input type="text" name="Date" /></td>
     <td><input type="text" name="Place" /></td>
     <td><input type="text" name="StartTime" /></td>
     <td><input type="text" name="Notes" /></td>
     <td><input type="text" name="Event" /></td>
	 </tr>

<tr>
<td colspan="6" align="center"><input type="submit" name="submit" value="Add Event" /></td>
</tr>
</table>
</form>
</td>
</tr>
</table>

Open in new window

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<title>insertevent.php</title>
</head>
<body>

<?php
<?php
mysql_connect("mysql", "xxx", "xxxx") or die ('Could not connect: ' . mysql_error());
mysql_select_db("RMDCRA");

$Points_Awarded = mysql_real_escape_string($_POST['Points_Awarded']);
$Date = mysql_real_escape_string($_POST['Date']);
$Place = mysql_real_escape_string($_POST['Place']);
$StartTime=mysql_real_escape_string($_POST['StartTime']);
$Notes=mysql_real_escape_string($_POST['Notes']);
$Event=mysql_real_escape_string($_POST['Event']);

$sql = ("INSERT INTO `RMDCRA`.`Schedule` (`Race_Number`, `Points_Awarded`, `Date`, `Place`, `StartTime`, `Notes`, `Event`)
    VALUES (NULL, '$Points_Awarded', '$Date', '$Place', '$StartTime', '$Notes', '$Event')") or die(mysql_error());
echo $sql;
echo mysql_error();

//header('Location: http://rmdcra.org/admin/Admin.php');
?> 

</body>
</html>

<!--
INSERT INTO `RMDCRA`.`Schedule` (
`Race_Number` ,
`PointsAwarded` ,
`Date` ,
`Place` ,
`StartTime` ,
`Notes` ,
`Event` 
)
VALUES (
NULL , '*', '2011-04-03', 'I-76 Speedway', NULL , NULL , 'Hot Laps'
);

-->

Open in new window

Capture.PNG
0
 
patrickm12981Author Commented:
When executed I get a blank page.
0
 
Mark BradyPrincipal Data EngineerCommented:
Fix up those few problems then we'll take another look at it.
0
 
Mark BradyPrincipal Data EngineerCommented:
You also have two openeing tags on the page. Remove line 11 <?php
0
 
Mark BradyPrincipal Data EngineerCommented:
You might want to ask a moderator to remove or mask line 12 on your last post (the 2nd page you posted) as it has your login details. Best to change these credentials now cause google may already have grabbed this page :)
0
 
patrickm12981Author Commented:
I noticed just after I posted it. I already asked the moderator.


Her is the result that I received after making the changes......

Unknown column 'Points_Awarded' in 'field list'
0
 
Mark BradyPrincipal Data EngineerCommented:
Sorry, I didn't picj=k that up. Change (Points_Awarded, to PointsAwarded

There is no _ underscore between the two words. The first line of your insert query (PointsAwarded, etc... must match EXACTLY to the column names in your table.
0
 
patrickm12981Author Commented:
NM -  fixed it.

Query worked!
0
 
Mark BradyPrincipal Data EngineerCommented:
No problems!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.