0

This is an annoying error...tried re-writing the code a few times...deleting and recreating the table...etc...still the same result:

" ...

You have an error in your SQL syntax; check the manual that corresponds to your MYSQL version for the right syntax to use near 'desc) VALUES ( '', '1', '1', '2007', '', '')' at line 1

..."

<?php
require_once "dbconnect.php"; // include the database information 
$day = $_POST["day"];
$month = $_POST["month"];
$year = $_POST["year"];
$link = $_POST["link"];
$desc = $_POST["desc"];
mysql_query("INSERT INTO calendar (id, day, month, year, link, desc) VALUES ( '', '$day', '$month', '$year', '$link', '$desc')") or die("something went wrong adding the event. MySQL said: ".mysql_error()); 
?>

I've checked the table...its the proper name being used "calendar" (and yup, all lower case)

the table consists of:
id INT NOT NULL AUTO_INCREMENT ,
day VARCHAR( 2 ) NOT NULL ,
month VARCHAR( 2 ) NOT NULL ,
year VARCHAR( 4 ) NOT NULL ,
link VARCHAR( 255 ) NOT NULL ,
desc TEXT NOT NULL

Anyone have any ideas what might be causing this? Been trying for over 4 hours to get this little bit of code to work....grrrrr! LOL

MYSQL is version 4.1.22

1
Contributor
1
Reply
2
Views
9 Years
Discussion Span
Last Post by verbob
0

OK!

It seems that some of my choice of variables may have been "reserved" words...simply putting them between ` ` and all is well

"INSERT INTO calendar (`id`, `day`, `month`, `year`, `link`, `desc`) VALUES (NULL, '$day', '$month', '$year', '$link', '$desc')"
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.