Page 2 of 2

Re: MYSQL syntax error

Posted: Sat Mar 05, 2011 10:21 am
by bangkok
maverickalex wrote:SUCCESS! well partial.
this

Code: Select all

 put "INSERT INTO phpvms_test (aircraft,flightnum,depicao,arricao,flighttime,fuelused,comments) VALUES ("& 'tAircraft' & "," & 'tFlightnum' & "," & 'tDepicao' & ","  & 'tArricao' & "," & 'tflighttime' & "," & 'tfuelused' & "," & 'tComments' &")" into tSQL
successfully sends to the database, However all that appears in the database are zero's that are sent??

Non, non, non. It can't work.

Let's recap :

-you want to insert strings
--> you need to use single quotes
-but your strings are variables
-->therefore you have to use the single quotes not attached to your variables names, but before and after double quotes !

Code: Select all

"& 'tAircraft' & "
means that you will insert the word tAircraft not the variable tAircraft. :)

So here is the query.

Code: Select all

 put "INSERT INTO phpvms_test (aircraft,flightnum,depicao,arricao,flighttime,fuelused,comments) VALUES ('"&tAircraft&"','" &tFlightnum&"','" &tDepicao&"','"& tArricao&"','"&tflighttime&"','"&tfuelused&"','"&tComments&"')" into tSQL
As I wrote before, if you have a problem with a SQL query, look at the query (first) not the script that have created the query (second).

It will help you to spot the problem, much more easily.

Other trick : when you strugle with a long UPDATE or INSERT query with many columns, first try a "short" version with only 1 or 2 columns. It will help you to "tune" your query, and to be sure it behaves correctly.

Anyway. You're almost done... But then I think you should peruse websites about MySQL. There are plenty, with very good tutorials.

Re: MYSQL syntax error

Posted: Sat Mar 05, 2011 2:11 pm
by BvG
Ok look, this is futile.

You just are not thinking about what you want to do, and how to achieve it. You do random things that are sure to not work, then post them here in an unreadable format, assuming the almighty forum will fix it for you. I will now stop to respond to this thread, as most other have already.

Please learn sql syntax and typing. Also read up about LC chunk expressions, variables, values and the sql commands.

Re: MYSQL syntax error

Posted: Sat Mar 05, 2011 10:34 pm
by maverickalex
Thanks, i'm sorry if it seems a PITA, i actually had it earlier (except i had the single quotes inside the doubles).

I have succesfully connected and sent to the database, thanks for your help. i truly do appreciate it. I understand how frustrating it can get when you feel like you are banging your head against a brick wall.
incidently i don't just expect people from the forum to complete my problems, only to nudge me in the right direction.

one issue i do have is when trying to use the field "load" and &'"tload&"'. would there be a problem using that as it is already a command?

Cheers
Alex

Re: MYSQL syntax error

Posted: Wed Mar 09, 2011 3:29 pm
by maverickalex
For some reason i couldnt get the variable tload to work, but changed it to tpass and it worked fine.
I have moved on a good way now. i have run into a part that leaves me scratching my head a little.

i have a field where the text is hilited and is a list of some 100 flighnumbers. it is populated by querying my database table names "schedules" and returns data such as "AVA101A".

The table "schedules" contains a column "flightnum" and "distance" which is calculated using a complex algorith involving latitude/logitudinal positions. Waaay over my head.

Image

What i want to do is something along these lines.

search the table schedules,column flightnumber for the hilitedtext of field "flightnum"
then when the flightnumber is found read across to the corresponding "distance" value.

Is it possible to do this way, or do i need to apply the calculation in my script?