PDA

View Full Version : What is wrong with this insert.



sn1per
03-27-2008, 04:29 PM
I'm sick, i'm at work, my head's killing me and i can't debug this. Do you see anything wrong?





INSERT INTO tracker(primary, email, ip, date, offer, network) VALUES ('', 'sniper@aol.com', '192.168.1.108', '20080327','dating','flux')

awol
03-27-2008, 07:08 PM
What error are you getting?

rmk
03-27-2008, 07:08 PM
is primary autoincrement or anything? what error are you getting

awol
03-27-2008, 07:10 PM
is primary autoincrement or anything? what error are you getting

Exactly what I was wondering.

If it's a PK or an auto_increment/identity, you can't insert into it.

Repins
03-27-2008, 08:40 PM
primary is auto. Error is thus:


#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 'primary, email, ip, date, offer, network) VALUES ('', 'sniper@aol.com', '192.168' at line 1

Repins
03-27-2008, 08:40 PM
g'damn i'm rusty

doolbman
03-28-2008, 12:40 AM
try
INSERT INTO tracker(`primary`, `email`,` ip`, `date`,` offer`, `network`) VALUES ('', 'sniper@aol.com', '192.168.1.108', '20080327','dating','flux')
also you shouldn't use date as a row name since it is also a function in mysql

Repins
03-28-2008, 09:08 AM
try
INSERT INTO tracker(`primary`, `email`,` ip`, `date`,` offer`, `network`) VALUES ('', 'sniper@aol.com', '192.168.1.108', '20080327','dating','flux')also you shouldn't use date as a row name since it is also a function in mysql


Thank you sir. Your 2 suggestions fixed it.

INSERT INTO tracker(`primary`, `email`,`ip`, `when`,`offer`, `network`) VALUES ('', 'sniper@aol.com', '192.168.1.108', '20080327','dating','flux')

mcbain
03-28-2008, 09:35 AM
just out of curiousity, since i dont use mysql that much. mostly oracle, sql server, sybase, db2.

when doing da insert statement

insert into table('these','fieldnames','need','to','be','enclo sed','in','quotes?') values ('bla','bla','bla','bla','bla','bla','bla','bla')

thats a question. do they need field names need to be enclosed in quotes?

awol
03-28-2008, 10:09 AM
just out of curiousity, since i dont use mysql that much. mostly oracle, sql server, sybase, db2.

when doing da insert statement

insert into table('these','fieldnames','need','to','be','enclo sed','in','quotes?') values ('bla','bla','bla','bla','bla','bla','bla','bla')

thats a question. do they need field names need to be enclosed in quotes?

They aren't single-quotes, they are backticks.

Which indicates the error was in the keywords PRIMARY and DATE being used as column names w/o backticks (akin to using [column_name] in SQL Server)