User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the MySQL section within the Web Development category of DaniWeb, a massive community of 391,563 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,705 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MySQL advertiser:
Views: 735 | Replies: 1 | Solved
Reply
Join Date: Sep 2007
Posts: 31
Reputation: verbob is an unknown quantity at this point 
Rep Power: 1
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 6: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: 1
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)

 

DaniWeb MySQL Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the MySQL Forum

All times are GMT -4. The time now is 10:04 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC