Page 1 of 1

SQL insert error

Posted: Mon Jun 11, 2007 6:40 pm
by pinehead18
I'll tell you what, having a day job sucks. Apparently it makes me stupid at php

Code: Select all

$sql = "INSERT INTO scene (section, body, by, date, title) VALUES ('section', 'body', 'by', 'date', 'title')";
Is my code


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 'by, date, title) VALUES ('section', 'body', 'by', 'date', 'title')' at line 1

is my error.

Please help relieve my pain.

Posted: Mon Jun 11, 2007 6:47 pm
by Benjamin
Some of your field names are reserved for use by mysql. Escape them with backticks. `

Posted: Mon Jun 11, 2007 6:52 pm
by pinehead18
Backtick (i know i know) you mean \?

Posted: Mon Jun 11, 2007 6:56 pm
by Benjamin
I mean `

Here is a bunch of them. ``````````````

Posted: Mon Jun 11, 2007 7:01 pm
by bdlang
astions wrote:Some of your field names are reserved for use by mysql. Escape them with backticks. `
Alternatively, change your column names.

MySQL Reserved Words

Posted: Mon Jun 11, 2007 7:42 pm
by TreyAU21
Field Types could be an issue too. I'm not 100% sure, but if the date field is a DATE, DATETIME, or TIMESTAMP field, won't passing it a simple string crap out? Although... it might just fill it with '0000-00-00 00:00:00'... I can't remember. I'm a little shabby. :oops:

Posted: Mon Jun 11, 2007 7:57 pm
by feyd
TreyAU21 wrote:Field Types could be an issue too. I'm not 100% sure, but if the date field is a DATE, DATETIME, or TIMESTAMP field, won't passing it a simple string crap out? Although... it might just fill it with '0000-00-00 00:00:00'... I can't remember. I'm a little shabby. :oops:
Simple strings are how DATE et al are set.