For Programmers: Free Programming Magazines  


Home > Archive > PHP SQL > March 2007 > Problems with SQL Query









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Problems with SQL Query
alex.waldner@gmail.com

2007-03-08, 7:00 pm

Hey there,

I'm trying to run a SQL Query but really can't find what's wrong with
it - I keep getting a 1064 error.

INSERT INTO logbook (id, pilot, date, acModel, acReg, blockOffAP,
blockOff, blockOnAP, blockOn, totalTime, PIC, Dual, Night, Instrument,
CC, landingsDay, landingsNight, comment) VALUES (NULL, '1',
'2007-03-08', 'C172', 'SELZF', 'ESOW', '1234', 'ESSA', '1256', '0.4',
'0', '0.4', '0', '0', '0', '0', '0', '')

Can anyone spot an error?

J.O. Aho

2007-03-08, 7:00 pm

alex.waldner@gmail.com wrote:
> Hey there,
>
> I'm trying to run a SQL Query but really can't find what's wrong with
> it - I keep getting a 1064 error.
>
> INSERT INTO logbook (id, pilot, date, acModel, acReg, blockOffAP,
> blockOff, blockOnAP, blockOn, totalTime, PIC, Dual, Night, Instrument,
> CC, landingsDay, landingsNight, comment) VALUES (NULL, '1',
> '2007-03-08', 'C172', 'SELZF', 'ESOW', '1234', 'ESSA', '1256', '0.4',
> '0', '0.4', '0', '0', '0', '0', '0', '')
>
> Can anyone spot an error?
>


And the whole error message was?

--

//Aho
Paul Lautman

2007-03-08, 7:00 pm

alex.waldner@gmail.com wrote:
> Hey there,
>
> I'm trying to run a SQL Query but really can't find what's wrong with
> it - I keep getting a 1064 error.
>
> INSERT INTO logbook (id, pilot, date, acModel, acReg, blockOffAP,
> blockOff, blockOnAP, blockOn, totalTime, PIC, Dual, Night, Instrument,
> CC, landingsDay, landingsNight, comment) VALUES (NULL, '1',
> '2007-03-08', 'C172', 'SELZF', 'ESOW', '1234', 'ESSA', '1256', '0.4',
> '0', '0.4', '0', '0', '0', '0', '0', '')
>
> Can anyone spot an error?


Try giving us the complete error message!


alex.waldner@gmail.com

2007-03-09, 4:01 am

Sorry - here you've got the whole error message.

An Error Was Encountered
Error Number: 1064

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 'Dual, Night, Instrument, CC, landingsDay, landingsNight,
comment) VALUES (NULL, ' at line 1

INSERT INTO logbook (id, pilot, date, acModel, acReg, blockOffAP,
blockOff, blockOnAP, blockOn, totalTime, PIC, Dual, Night, Instrument,
CC, landingsDay, landingsNight, comment) VALUES (NULL, '1',
'2007-03-08', 'C172', 'SELZF', 'ESOW', '1234', 'ESSA', '1256', '0.4',
'0', '0.4', '0', '0', '0', '0', '0', NULL)

J.O. Aho

2007-03-09, 4:01 am

alex.waldner@gmail.com wrote:
> Sorry - here you've got the whole error message.
>
> An Error Was Encountered
> Error Number: 1064
>
> 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 'Dual, Night, Instrument, CC, landingsDay, landingsNight,
> comment) VALUES (NULL, ' at line 1
>
> INSERT INTO logbook (id, pilot, date, acModel, acReg, blockOffAP,
> blockOff, blockOnAP, blockOn, totalTime, PIC, Dual, Night, Instrument,
> CC, landingsDay, landingsNight, comment) VALUES (NULL, '1',
> '2007-03-08', 'C172', 'SELZF', 'ESOW', '1234', 'ESSA', '1256', '0.4',
> '0', '0.4', '0', '0', '0', '0', '0', NULL)
>


Dual is a reserved word and should really not be used for
database/table/column/function/procedure names, I strongly recommend you
rename it, you can also use the "single quotes" ``.

Notice the difference from the usual single quote ' and the one used for
database/table/column names which is tittle a bit `.

--

//Aho
Captain Paralytic

2007-03-09, 7:01 pm

On 9 Mar, 06:29, alex.wald...@gmail.com wrote:
> Sorry - here you've got the whole error message.
>
> An Error Was Encountered
> Error Number: 1064
>
> 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 'Dual, Night, Instrument, CC, landingsDay, landingsNight,
> comment) VALUES (NULL, ' at line 1
>
> INSERT INTO logbook (id, pilot, date, acModel, acReg, blockOffAP,
> blockOff, blockOnAP, blockOn, totalTime, PIC, Dual, Night, Instrument,
> CC, landingsDay, landingsNight, comment) VALUES (NULL, '1',
> '2007-03-08', 'C172', 'SELZF', 'ESOW', '1234', 'ESSA', '1256', '0.4',
> '0', '0.4', '0', '0', '0', '0', '0', NULL)


Following on from Aho, I always "tick" all my table/alias/column names
as a matter of course. Saves lots of headaches e.g. having a column
called `group`.

iceman

2007-03-09, 7:01 pm

alex.waldner@gmail.com napisał(a):
> Sorry - here you've got the whole error message.
>
> An Error Was Encountered
> Error Number: 1064
>
> 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 'Dual, Night, Instrument, CC, landingsDay, landingsNight,
> comment) VALUES (NULL, ' at line 1
>
> INSERT INTO logbook (id, pilot, date, acModel, acReg, blockOffAP,
> blockOff, blockOnAP, blockOn, totalTime, PIC, Dual, Night, Instrument,
> CC, landingsDay, landingsNight, comment) VALUES (NULL, '1',
> '2007-03-08', 'C172', 'SELZF', 'ESOW', '1234', 'ESSA', '1256', '0.4',
> '0', '0.4', '0', '0', '0', '0', '0', NULL)
>


could you show me how do you create this table? maybe id field cann't be
NULL
Alex

2007-03-09, 7:01 pm

On Mar 9, 8:36 am, "J.O. Aho" <u...@example.net> wrote:
> alex.wald...@gmail.com wrote:
>
>
>
>
> Dual is a reserved word and should really not be used for
> database/table/column/function/procedure names, I strongly recommend you
> rename it, you can also use the "single quotes" ``.
>
> Notice the difference from the usual single quote ' and the one used for
> database/table/column names which is tittle a bit `.
>
> --
>
> //Aho


Problem solved :D

The issue was the 'Dual'. I renamed it and now it works just fine.
Thanks a lot for your help all of you!

J.O. Aho

2007-03-10, 8:01 am

Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: individual.net b2gjEetBhyb334Nb44YVaQWDSagZ5OMdEmUNNRsV
Gz0vPM1zs9
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9a1) Gecko/20060131 SeaMonkey/1.5a
In-Reply-To: <1173482428.981346.54660@30g2000cwc.googlegroups.com>
Xref: number1.nntp.dca.giganews.com alt.php.sql:27397

Alex wrote:

> Problem solved :D
> The issue was the 'Dual'. I renamed it and now it works just fine.
> Thanks a lot for your help all of you!
>

Here is a list of reserved words in MySQL, it will apply quite well into other
sql databases too: http://dev.mysql.com/doc/refman/5.0...rved-words.html

--

//Aho
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com