Posts: 427
Name: Stuart
Location: Glasgow, Scotland
|
So......another problem.
I have a form that when submitted adds the data to a database. I have at least 2 other forms like this within my site and they work perfectly . However this one doesn't, the code is, as far as i can see, exactly the same as the other forms (with the table data etc changed). The error i get is:
Couldn't add data to "reviews" table: 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 'show, body, rating) values('Stoot', 'Hello', 'Hellooo', '7'
The code i'm using is:
PHP Code:
include("config.php");
$name_submit = $_POST['name'];
$show_submit = $_POST['show'];
$body_submit = $_POST['body'];
$rating_submit = $_POST['rating'];
if ($name_submit == "" OR $show_submit == "" OR $body_submit == "" OR $rating_submit == "") {
print "You must enter something in each field!";
print "<br>";
print "<br>";
print "<a href = \"javascript:history.back(-1)\">Return and correct...</a>";
} else {
$query = "INSERT INTO reviews ( name, show, body, rating)
values('$name_submit', '$show_submit', '$body_submit', '$rating_submit')";
mysql_query($query)
or die ("Couldn't add data to \"reviews\" table: "
.mysql_error() );
print "Your review has been submitted. Thanks!";
print "<br>";
print "<br>";
print "<a href = \"gigs.php?skin=$skin\">Back to Gigs listings</a><br><br>";
}
I really can't figure it out, so any help would be great. 
Sorry for keeping asking questions. Cheers
Stoot
|