Welcome to Dream.In.Code
Become an Expert!

Join 149,537 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,528 people online right now. Registration is fast and FREE... Join Now!




SQL Error... Wha?!

 
Reply to this topicStart new topic

SQL Error... Wha?!

skyhawk133
11 Jun, 2002 - 12:50 PM
Post #1

Head DIC Head
Group Icon

Joined: 17 Mar, 2001
Posts: 15,262



Thanked: 61 times
Dream Kudos: 1650
Expert In: Web Development

My Contributions
I've looked at this statement for 30 minutes now... there is NOTHING wrong with it. But have a look... see anything messed up?

SQL
INSERT INTO retailers (id, company, name, address, city, state, zip, phone, url, description, lines, group, date_added, months, email) VALUES ('$company', '$name', '$address', '$city', '$state', '$zip', '$phone', '$addy', '$description', '$lines', '$group', '$today', '$months', '$email')

User is offlineProfile CardPM
+Quote Post

fyrestorm
RE: SQL Error... Wha?!
11 Jun, 2002 - 01:05 PM
Post #2

D.I.C Lover
Group Icon

Joined: 4 Apr, 2002
Posts: 3,103



Thanked: 2 times
Dream Kudos: 228
My Contributions
take out id and see what happens or add '' as the first thing in VALUES
User is offlineProfile CardPM
+Quote Post

skyhawk133
RE: SQL Error... Wha?!
11 Jun, 2002 - 01:09 PM
Post #3

Head DIC Head
Group Icon

Joined: 17 Mar, 2001
Posts: 15,262



Thanked: 61 times
Dream Kudos: 1650
Expert In: Web Development

My Contributions
QUOTE(skyhawk133 @ Jun 11 2002, 02:50 PM)
I've looked at this statement for 30 minutes now... there is NOTHING wrong with it. But have a look... see anything messed up?

SQL
INSERT INTO retailers (id, company, name, address, city, state, zip, phone, url, description, lines, group, date_added, months, email) VALUES ('$company', '$name', '$address', '$city', '$state', '$zip', '$phone', '$addy', '$description', '$lines', '$group', '$today', '$months', '$email')

My boss did this and it works fine:
SQL
INSERT INTO `retailers` (`id`, `company`, `name`, `address`, `city`, `state`, `zip`, `phone`, `url`, `description`, `lines`, `group`, `date_added`, `months`, `email`) VALUES ('', '$company', '$name', '$address', '$city', '$state', '$zip', '$phone', '$addy', '$description', '$lines', '$group', '$today', '$months', '$email')


*shrugs* Strange how picky mySQL is.
User is offlineProfile CardPM
+Quote Post

Cookie Mobster
RE: SQL Error... Wha?!
11 Jun, 2002 - 01:20 PM
Post #4

nooneenooneenooonee
Group Icon

Joined: 12 Oct, 2001
Posts: 4,723



Thanked: 1 times
Dream Kudos: 18
My Contributions
I'm sure that fyrestorm nailed it. the lack of an empty field for id was making the number of fields one larger then the data supplied.

Cheers Sam
User is offlineProfile CardPM
+Quote Post

RE: SQL Error... Wha?!
11 Jun, 2002 - 01:24 PM
Post #5




Joined: --
Posts: 0

He types faster than he thinks... in the original code the id was left out of both the fields and the values...

Hoopster
User is offlinePM
+Quote Post

klewlis
RE: SQL Error... Wha?!
11 Jun, 2002 - 01:34 PM
Post #6

cur tu me vexas?
*****

Joined: 9 Nov, 2001
Posts: 1,723

That's odd, I've never had to quote the column or table names with either mySQL or SQL Server.... I wonder what the deal is.

A difference between PHP and ASP, I wonder?
User is offlineProfile CardPM
+Quote Post

RE: SQL Error... Wha?!
11 Jun, 2002 - 01:39 PM
Post #7




Joined: --
Posts: 0

You don't have to quote the columns I was too lazy to remove them after phpMyAdmin put them in.

Hoopster
User is offlinePM
+Quote Post

Cookie Mobster
RE: SQL Error... Wha?!
11 Jun, 2002 - 01:42 PM
Post #8

nooneenooneenooonee
Group Icon

Joined: 12 Oct, 2001
Posts: 4,723



Thanked: 1 times
Dream Kudos: 18
My Contributions
The only thing I could see that being caused by is if the field is set to NOT NULL, but with AUTO_INCREMENT ON it should work around it. Oh well all that matters is that the boss showed him... well... who is boss. biggrin.gif

Cheers Sam
User is offlineProfile CardPM
+Quote Post

fyrestorm
RE: SQL Error... Wha?!
11 Jun, 2002 - 06:47 PM
Post #9

D.I.C Lover
Group Icon

Joined: 4 Apr, 2002
Posts: 3,103



Thanked: 2 times
Dream Kudos: 228
My Contributions
QUOTE(smckone @ Jun 11 2002, 03:42 PM)
The only thing I could see that being caused by is if the field is set to NOT NULL, but with AUTO_INCREMENT ON it should work around it. Oh well all that matters is that the boss showed him... well... who is boss. biggrin.gif

Cheers Sam

the boss has a habit of showing him, who is boss laugh.gif
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 09:16PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month