Avatar billede boxerfjaes Nybegynder
19. juli 2009 - 01:06 Der er 6 kommentarer og
1 løsning

syntax to use near '' at line 1

Hej!

Jeg er stødt på problemer, får følgende fejl meddelelse:
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 '' at line 1.

mysql_query("INSERT INTO stages (stage_id, code, ".
    "distance_1, altitude_1, RHO_1, surface_1, Crr_1, gradient_1, sinTHETA_1, wind_1, difficulty_1, hill#3_1, hill#4_1, Cd_1  areaBONUS_1, CdPACE_1,".
    "distance_2, altitude_2, RHO_2, surface_2, Crr_2, gradient_2, sinTHETA_2, wind_2, difficulty_2, hill#3_2, hill#4_2, Cd_2  areaBONUS_2, CdPACE_2,".
    "distance_3, altitude_3, RHO_3, surface_3, Crr_3, gradient_3, sinTHETA_3, wind_3, difficulty_3, hill#3_3, hill#4_3, Cd_3  areaBONUS_3, CdPACE_3,".
    "distance_4, altitude_4, RHO_4, surface_4, Crr_4, gradient_4, sinTHETA_4, wind_4, difficulty_4, hill#3_4, hill#4_4, Cd_4  areaBONUS_4, CdPACE_4,".
    "distance_5, altitude_5, RHO_5, surface_5, Crr_5, gradient_5, sinTHETA_5, wind_5, difficulty_5, hill#3_5, hill#4_5, Cd_5  areaBONUS_5, CdPACE_5,".
    "distance_6, altitude_6, RHO_6, surface_6, Crr_6, gradient_6, sinTHETA_6, wind_6, difficulty_6, hill#3_6, hill#4_6, Cd_6  areaBONUS_6, CdPACE_6,".
    "distance_7, altitude_7, RHO_7, surface_7, Crr_7, gradient_7, sinTHETA_7, wind_7, difficulty_7, hill#3_7, hill#4_7, Cd_7, areaBONUS_7, CdPACE_7,".
    "distance_8, altitude_8, RHO_8, surface_8, Crr_8, gradient_8, sinTHETA_8, wind_8, difficulty_8, hill#3_8, hill#4_8, Cd_8, areaBONUS_8, CdPACE_8,".
    "distance_9, altitude_9, RHO_9, surface_9, Crr_9, gradient_9, sinTHETA_9, wind_9, difficulty_9, hill#3_9, hill#4_9, Cd_9, areaBONUS_9, CdPACE_9,".
    "distance_f, altitude_f, RHO_f, surface_f, Crr_f, gradient_f, sinTHETA_f, wind_f, difficulty_f, hill#3_f, hill#4_f, Cd_f, areaBONUS_f, CdPACE_f) ".
    "VALUES ('$stageid', '$code', ".
    "'$dis1', '$alt1', '$rho1', '$sur1', '$crr1', '$gra1', '$sin1', '$win1', '$dif1', '$hi31', '$hi41', '$cd1', '$are1', '$cdp1',".
    "'$dis2', '$alt2', '$rho2', '$sur2', '$crr2', '$gra2', '$sin2', '$win2', '$dif2', '$hi32', '$hi42', '$cd2', '$are2', '$cdp2',".
    "'$dis3', '$alt3', '$rho3', '$sur3', '$crr3', '$gra3', '$sin3', '$win3', '$dif3', '$hi33', '$hi43', '$cd3', '$are3', '$cdp3',".
    "'$dis4', '$alt4', '$rho4', '$sur4', '$crr4', '$gra4', '$sin4', '$win4', '$dif4', '$hi34', '$hi44', '$cd4', '$are4', '$cdp4',".
    "'$dis5', '$alt5', '$rho5', '$sur5', '$crr5', '$gra5', '$sin5', '$win5', '$dif5', '$hi35', '$hi45', '$cd5', '$are5', '$cdp5',".
    "'$dis6', '$alt6', '$rho6', '$sur6', '$crr6', '$gra6', '$sin6', '$win6', '$dif6', '$hi36', '$hi46', '$cd6', '$are6', '$cdp6',".
    "'$dis7', '$alt7', '$rho7', '$sur7', '$crr7', '$gra7', '$sin7', '$win7', '$dif7', '$hi37', '$hi47', '$cd7', '$are7', '$cdp7',".
    "'$dis8', '$alt8', '$rho8', '$sur8', '$crr8', '$gra8', '$sin8', '$win8', '$dif8', '$hi38', '$hi48', '$cd8', '$are8', '$cdp8',".
    "'$dis9', '$alt9', '$rho9', '$sur9', '$crr9', '$gra9', '$sin9', '$win9', '$dif9', '$hi39', '$hi49', '$cd9', '$are9', '$cdp9',".
    "'$disf', '$altf', '$rhof', '$surf', '$crrf', '$graf', '$sinf', '$winf', '$diff', '$hi3f', '$hi4f', '$cdf', '$aref', '$cdpf')") OR DIE(mysql_error());

Håber i kan hjælpe mig.
Avatar billede showsource Seniormester
19. juli 2009 - 09:00 #1
Jahh, hvad er
".
    "
mellem code og distance_1 ?
Avatar billede erikjacobsen Ekspert
19. juli 2009 - 09:45 #2
Det er nok bare tekstsammensætning, showsource.

Men man kan ikke have navne med # i. Men du kan skrive dem som:  `hill#3_1`
Avatar billede boxerfjaes Nybegynder
19. juli 2009 - 11:17 #3
Nu har jeg prøvet at fjerne "." og sætter ' om navne med #... Det hjalp tilsyneladende, men nu får jeg følgende fejl besked:

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 ''hill#3_1','hill#4_1',Cd_1,areaBONUS_1,CdPACE_1,distance_2,altitude_2,RHO_2,surf' at line 1

Coden ser således ud:

mysql_query("INSERT INTO stages(stage_id,code,distance_1,altitude_1,RHO_1,surface_1,Crr_1,gradient_1,sinTHETA_1,wind_1,difficulty_1,'hill#3_1','hill#4_1',Cd_1,areaBONUS_1,CdPACE_1,distance_2,altitude_2,RHO_2,surface_2,Crr_2,gradient_2,sinTHETA_2,wind_2,difficulty_2,'hill#3_2','hill#4_2',Cd_2,areaBONUS_2,CdPACE_2,distance_3,altitude_3,RHO_3,surface_3,Crr_3,gradient_3,sinTHETA_3,wind_3,difficulty_3,'hill#3_3','hill#4_3',Cd_3,areaBONUS_3,CdPACE_3,distance_4,altitude_4,RHO_4,surface_4,Crr_4,gradient_4,sinTHETA_4,wind_4,difficulty_4,'hill#3_4','hill#4_4',Cd_4,areaBONUS_4,CdPACE_4,distance_5,altitude_5,RHO_5,surface_5,Crr_5,gradient_5,sinTHETA_5,wind_5,difficulty_5,'hill#3_5','hill#4_5',Cd_5,areaBONUS_5,CdPACE_5,distance_6,altitude_6,RHO_6,surface_6,Crr_6,gradient_6,sinTHETA_6,wind_6,difficulty_6,'hill#3_6','hill#4_6',Cd_6,areaBONUS_6,CdPACE_6,distance_7,altitude_7,RHO_7,surface_7,Crr_7,gradient_7,sinTHETA_7,wind_7,difficulty_7,'hill#3_7','hill#4_7',Cd_7,areaBONUS_7,CdPACE_7,distance_8,altitude_8,RHO_8,surface_8,Crr_8,gradient_8,sinTHETA_8,wind_8,difficulty_8,'hill#3_8','hill#4_8',Cd_8,areaBONUS_8,CdPACE_8,distance_9,altitude_9,RHO_9,surface_9,Crr_9,gradient_9,sinTHETA_9,wind_9,difficulty_9,'hill#3_9','hill#4_9',Cd_9,areaBONUS_9,CdPACE_9,distance_f,altitude_f,RHO_f,surface_f,Crr_f,gradient_f,sinTHETA_f,wind_f,difficulty_f,'hill#3_f','hill#4_f',Cd_f,areaBONUS_f,CdPACE_f) VALUES ('$stageid','$code','$dis1','$alt1','$rho1','$sur1','$crr1','$gra1','$sin1','$win1','$dif1','$hi31','$hi41','$cd1','$are1','$cdp1','$dis2','$alt2','$rho2','$sur2','$crr2','$gra2','$sin2','$win2','$dif2','$hi32','$hi42','$cd2','$are2','$cdp2','$dis3','$alt3','$rho3','$sur3','$crr3','$gra3','$sin3','$win3','$dif3','$hi33','$hi43','$cd3','$are3','$cdp3','$dis4','$alt4','$rho4','$sur4','$crr4','$gra4','$sin4','$win4','$dif4','$hi34','$hi44','$cd4','$are4','$cdp4','$dis5','$alt5','$rho5','$sur5','$crr5','$gra5','$sin5','$win5','$dif5','$hi35','$hi45','$cd5','$are5','$cdp5','$dis6','$alt6','$rho6','$sur6','$crr6','$gra6','$sin6','$win6','$dif6','$hi36','$hi46','$cd6','$are6','$cdp6','$dis7','$alt7','$rho7','$sur7','$crr7','$gra7','$sin7','$win7','$dif7','$hi37','$hi47','$cd7','$are7','$cdp7','$dis8','$alt8','$rho8','$sur8','$crr8','$gra8','$sin8','$win8','$dif8','$hi38','$hi48','$cd8','$are8','$cdp8','$dis9','$alt9','$rho9','$sur9','$crr9','$gra9','$sin9','$win9','$dif9','$hi39','$hi49','$cd9','$are9','$cdp9','$disf','$altf','$rhof','$surf','$crrf','$graf','$sinf','$winf','$diff','$hi3f','$hi4f','$cdf','$aref','$cdpf')") OR DIE(mysql_error());
Avatar billede erikjacobsen Ekspert
19. juli 2009 - 11:42 #4
Du skal sætte ` omkring, ikke '

Og det med "."-erne var nu helt ok
Avatar billede boxerfjaes Nybegynder
19. juli 2009 - 12:29 #5
Det virker perfekt! Mange tak. Skriver du et svar..
Avatar billede erikjacobsen Ekspert
19. juli 2009 - 12:34 #6
Jeg samler slet ikke på point, tak.
Avatar billede boxerfjaes Nybegynder
19. juli 2009 - 17:04 #7
lukket..
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Computerworld tilbyder specialiserede kurser i database-management

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester