Re: mySQL Problem
- From: Jerry Stuckle <jstucklex@xxxxxxxxxxxxx>
- Date: Thu, 08 Nov 2007 08:31:15 -0500
AnrDaemon wrote:
Greetings, Steve.
In reply to Your message dated Wednesday, November 7, 2007, 20:19:23,
"Einstein30000" <dominic_ernst@xxxxxx> wrote in message news:1194453026.587359.180320@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxHi,
in one of my php-scripts is the following query (with an already open
db-connection):
$q = "INSERT INTO main (name, img, descr, from, size, format, cat,
host, link, date) VALUES ('$name', '$img', '$descr', '$user', '$size',
'$format', '$cat', '$host', '$link', '$date')" or die(mysql_error());
And when the query gets executed i get back the following error:
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 'from, size, format, cat, host, link, date) VALUES ('bla', '-',
'keine', 'Holgi',' at line 1
Whats wrong here?!
your sql statement is F.U.C.K.E.D !!!
Agree but not in the way You think about.
hmmmm...perhaps you'll now see the value in FORMATTING your queries where a HUMAN BEING can read it. makes it easier to debug. :)
Actually, problem is proper quoting, not the format or anything else.
$sql = "
INSERT INTO main
(
`name` ,
`img` ,
`descr` ,
`from` ,
`size` ,
`format` ,
`cat` ,
`host` ,
`link` ,
`date`
)
That way. All should work now.
No, the REAL solution is to not use reserved words as column names. Then you don't need the quotes - which, BTW, are a MySQL extension to the SQL standard and won't work on any other RDBMS I'm familiar with.
And it's better to ask SQL questions in a SQL newsgroup.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@xxxxxxxxxxxxx
==================
.
- Follow-Ups:
- Re: mySQL Problem
- From: AnrDaemon
- Re: mySQL Problem
- References:
- mySQL Problem
- From: Einstein30000
- Re: mySQL Problem
- From: Steve
- Re: mySQL Problem
- From: AnrDaemon
- mySQL Problem
- Prev by Date: Re: mySQL Problem
- Next by Date: Re: Furthering my education in OOP - where/how can one learn professional skills?
- Previous by thread: Re: mySQL Problem
- Next by thread: Re: mySQL Problem
- Index(es):
Relevant Pages
|