RSS Forums RSS
Please support our MySQL advertiser: Programming Forums
Views: 873 | Replies: 1 | Solved | Thread Tools  Display Modes
Reply
Join Date: Sep 2007
Posts: 31
Reputation: verbob is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 1
verbob verbob is offline Offline
Light Poster

syntax error....

  #1  
Nov 17th, 2007
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
Last edited by verbob : Nov 17th, 2007 at 7:13 pm.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Sep 2007
Posts: 31
Reputation: verbob is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 1
verbob verbob is offline Offline
Light Poster

Re: syntax error....

  #2  
Nov 17th, 2007
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')"
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 3:55 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC