Re: mySQL Problem




"AnrDaemon" <anrdaemon@xxxxxxxxxxx> wrote in message
news:628830764.20071108121442@xxxxxxxxxxxxxx
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@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi,

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.

in that it currently doesn't work? is that all? it would help you be
understood better were you to allow a little more verbage than that. :)

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.

as for 'anything else'. no, using reserved words as descriptives for db
objects (tables, columns, triggers, udf's, etc.) is such a huge no-no that a
dba would approach your boss and make a *strong* case for terminating your
ass. or, if you consult, a client thanking you for your time and parting
with your company in short order.

as for format? well, i'll be happy to one-line a couple of statistical
queries for you here. i'd venture a guess that if you can read it, you'd
have a shot at figuring out the calculations involved. if you don't (or
someone else with a question about it who can't simply read the query), then
i'd love to see you express to another person exactly where in the query you
don't get the actual logic that's going on. this is another reason to
format. 'hey, explain to me the calculation made on line 322.' that's v.
'hey, explain to me the calculations made near sum(avg(udf...no, not that
one...it's about the third one when your start at the top and search in your
editor for sum(avg(udf'. get the picture?

$sql = "
INSERT INTO main
(
`name` ,
`img` ,
`descr` ,
`from` ,
`size` ,
`format` ,
`cat` ,
`host` ,
`link` ,
`date`
)

That way. All should work now.

until you forget what reserved words you've used and in which tables...or,
until you want (or your boss/client wants) to use another db. if you have a
large code base, how many man hours have you forced your employer to spend
fixing your (deliberate) oversight? hint, the larger the code base, the more
likely it is that you'll be looking for other means of income.


.



Relevant Pages

  • Re: formatting a calculated number field on a form
    ... > A query in an MDB file CAN call a user-defined function. ... > function name is Age and it returns a double. ... The user will certainly "notice" if a patient was born on Jan ... I just want control over the *display format* of a number ...
    (microsoft.public.access.forms)
  • RE: Query count then average.
    ... What was happening in my database was the query returned the ... "Ken Sheridan" wrote: ... It probably depends where you set the Format property. ... "Robert F." ...
    (microsoft.public.access.queries)
  • RE: Cannot get code to work for API Save Dialog Box
    ... I got it working to format correctly now. ... that table in my other queries and union query. ... The code is actually working by giving me the totals I need. ... The first spreadsheet placed where I told it to be contains the incorrect ...
    (microsoft.public.access.forms)
  • RE: Excel & MS Query caused compile errors
    ... My data is in an Excel file called ... The format of it were distorted after copying and pasting. ... Microsoft SQL Server 2000, which requires a server, VBA or Microsoft Query ...
    (microsoft.public.excel.programming)
  • RE: Query count then average.
    ... It probably depends where you set the Format property. ... "Robert F." ... "Ken Sheridan" wrote: ... You can format the column in the query: ...
    (microsoft.public.access.queries)