I am attempting to send the data from a set of radio buttons to my MySQL Database so that I am able to get people to review the site.
When I did my initial test with a single radio button in a test database all went well, however when I added more I am getting an unusual error. It works when I comment out the other values and leave only one to be inserted into the database, but unless that happens I get the errors.
My HTML is:
<form action='../Action/Improv.php' method='POST'>
<table>
<tr>
<td> First Impressions: </td>
<td>
1<input type='radio' name='Impressions' value = "1" >
2<input type='radio' name='Impressions' value = "2" >
3<input type='radio' name='Impressions' value = "3" >
4<input type='radio' name='Impressions' value = "4" >
5<input type='radio' name='Impressions' value = "5" > <br><br>
</tr>
<tr>
<td> Appearance: </td>
<td>
1<input type='radio' name='Appearance' value = "1" >
2<input type='radio' name='Appearance' value = "2" >
3<input type='radio' name='Appearance' value = "3" >
4<input type='radio' name='Appearance' value = "4" >
5<input type='radio' name='Appearance' value = "5" > <br><br>
</tr>
<tr>
<td> Ease of Use: </td>
<td>
1<input type='radio' name='Use' value = "1" >
2<input type='radio' name='Use' value = "2" >
3<input type='radio' name='Use' value = "3" >
4<input type='radio' name='Use' value = "4" >
5<input type='radio' name='Use' value = "5" > <br><br>
</tr>
<td> Content: </td>
<td>
1<input type='radio' name='Content' value = "1" >
2<input type='radio' name='Content' value = "2" >
3<input type='radio' name='Content' value = "3" >
4<input type='radio' name='Content' value = "4" >
5<input type='radio' name='Content' value = "5" > <br><br>
</tr>
<tr>
<td> Other Comments: </td>
<td>
<textarea rows = "15" cols = "50" input type='text' name='Comments' maxlength = "1000" ></textarea></td>
</tr>
<tr>
<td id = "Repeat"> Repeat: </td>
<td id = "Repeat"> <input type ='text' name='Repeat' >
</tr>
</table>
<br><br><input type='submit' name = "Submit" value='Submit'> <br><br>
</form>
And my PHP Code is:
<?php
//Collect User Input from Form
$Impressions = $_POST['Impressions'];
$Appearance = $_POST['Appearance'];
$Use = $_POST['Use'];
$Content = $_POST['Content'];
$UComments = $_POST['Comments'];
$Repeat = $_POST['Repeat'];
$Date = date("Y/m/d H:i:s");
//If Repeat Is Filled - BOT WARNING
if ($Repeat) {
die ("BOT WARNING - ACCESS DENIED");
} else {
//Replace Non-Accepted Characters
$CComments = preg_replace('/[^a-zA-Z0-9\,\.\@\!\?\s ]/','*',$UComments);
//Connect to the Database
mysql_connect("localhost", "root", "pass") or die("Error Connecting to SQL");
mysql_select_db("myDB") or die("Error Connecting to the Database");
//Prevent Code From Executing
$Comments = mysql_real_escape_string($CComments);
//Enter Data Into Database
$query = mysql_query("INSERT INTO Improv (ID, Impressions, Appearance, Use, Content, Comments, Date) VALUES
('NULL','$Impressions','$Appearance','$Use','$Content','$Comments','$Date')") or die (mysql_error());
}
?>
The error I recieve is when I tell PHP to display the problem at
$query = mysql_query("INSERT INTO Improv (ID, Impressions, Appearance, Use, Content, Comments, Date) VALUES
('NULL','$Impressions','$Appearance','$Use','$Content','$Comments','$Date')") or die (mysql_error());
}
And the error is: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Use, Content, Comments, Date) VALUES ('NULL','5','4','3','2','The design is ' at line 1
I am rather new to PHP and I am slightly confused about this, could someone please point me as to what the error means and how I would fix it? Thank you.