Hej mina vänner Tänk att man aldrig lär sig kolla datumet innan..Skicka till databasen
Någon som skulle vilja hjälpa mig med ett problem? Jag ska skicka mina odds för respektive match till databasen. Jag skickar dom till filen "tippa_odds_ny_add.asp", där jag har skrivit så här:
TimeTips = Now()
Connect.Execute ("INSERT INTO Tips_odds_ny (GameID,UserID,TimeTips) VALUES("& GAME_ &","& UserID &",'"& TimeTips &"')") Men när jag klickar på tippaknappen får jag detta felmeddelande:
Microsoft JET Database Engine error '80040e14'
Syntax error in INSERT INTO statement.
/tippa_odds_ny_add.asp, line 6
Detta är rad 6 i tippa_odds_ny_add.asp:
Connect.Execute ("INSERT INTO Tips_odds_ny (GameID,UserID,TimeTips) VALUES("& GAME_ &","& UserID &",'"& TimeTips &"')")
Här är min kod till sidan där jag har matcherna och oddsen.
<%
Call dbConnect()
If Session("UserID") = FALSE Then
Response.Write"<font face=""Verdana"" size=""2"" color=""800000""><b>Du måste vara inloggad för att tippa</b></font><br>"
End If
Select Case Request.Querystring("tippa")
Case "idag"
sSQL1 = "SELECT SerieID,Spelstopp,HomeTeam,AwayTeam,GameID,Odds1,OddsX,Odds2 FROM Games_odds WHERE DatePart(""y"",Spelstopp,2,2) = DatePart(""y"",Date(),2,2) AND NOT Spelstopp < Now() AND Active = 1 ORDER BY Spelstopp, HomeTeam"
Set rsGames=Connect.Execute(sSQL1)
Case "imorgon"
sSQL2 = "SELECT SerieID,Spelstopp,HomeTeam,AwayTeam,GameID,Odds1,OddsX,Odds2 FROM Games_odds WHERE Datepart(""y"",Spelstopp,2,2) = Datepart(""y"",Date(),2,2) + 1 AND Active = 1 ORDER BY Spelstopp, HomeTeam"
Set rsGames=Connect.Execute(sSQL2)
Case "denna"
sSQL3 = "SELECT SerieID,Spelstopp,HomeTeam,AwayTeam,GameID,Odds1,OddsX,Odds2 FROM Games_odds WHERE DatePart(""ww"",Spelstopp,2,2) = DatePart(""ww"",Date(),2,2) AND NOT Spelstopp < Now() AND Active = 1 ORDER BY Spelstopp, HomeTeam"
Set rsGames=Connect.Execute(sSQL3)
Case "next"
sSQL4 = "SELECT SerieID,Spelstopp,HomeTeam,AwayTeam,GameID,Odds1,OddsX,Odds2 FROM Games_odds WHERE Datepart(""ww"",Spelstopp,2,2) = Datepart(""ww"",Date(),2,2) + 1 AND Active = 1 ORDER BY Spelstopp, HomeTeam"
Set rsGames=Connect.Execute(sSQL4)
Case Else
sSQL5 = "SELECT SerieID,Spelstopp,HomeTeam,AwayTeam,GameID,Odds1,OddsX,Odds2 FROM Games_odds WHERE Datepart(""y"",Spelstopp,2,2) = Datepart(""y"",Date(),2,2) AND NOT Spelstopp < Now() AND Active = 1 ORDER BY Spelstopp, HomeTeam"
Set rsGames=Connect.Execute(sSQL5)
End Select
If rsGames.BOF Then
Response.Write"Inga fler matcher att tippa idag.<br>"
Else
arrRows = rsGames.GetRows()
'#######################################
' Kollar antal kolumner, startar på 0
intCols = uBound(arrRows,1)
' Kollar antal rader, startar på 0
intRows = uBound(arrRows,2)
Response.write("<br><br><table border=""0"" width=""660"" cellspacing=""0"" cellpadding=""0"" id=""tippa"" class="""">")
Response.write("<td class=""borderbottom_2"" width=""40"" align=""center""><font face=""Verdana"" color=""0000ff"" size=""2"">Liga</td>")
Response.write("<td class=""borderbottom_2"" width=""160"" align=""left""><font face=""Verdana"" color=""0000ff"" size=""2"">Spelstopp</td>")
Response.write("<td class=""borderbottom_2"" width=""240"" align=""left""><font face=""Verdana"" color=""0000ff"" size=""2"">Match</td>")
Response.write("<td class=""borderbottom_2"" width=""70"" align=""center""><font face=""Verdana"" color=""0000ff"" size=""2"">1</td>")
Response.write("<td class=""borderbottom_2"" width=""70"" align=""center""><font face=""Verdana"" color=""0000ff"" size=""2"">X</td>")
Response.write("<td class=""borderbottom_2"" width=""70"" align=""center""><font face=""Verdana"" color=""0000ff"" size=""2"">2</font></td></tr>")
For cRows = 0 to intRows
sSQL2 = "SELECT * FROM qGamesTips_odds WHERE UserID = "& Session("UserID") &" AND GameID = "& arrRows(4, cRows) &" "
Set rsTips=Connect.Execute(sSQL2)
If Farg = "<tr class=""Tabell"">" Then
Farg = "<tr class=""Tabell"">"
Else
Farg = "<tr class=""Tabell"">"
End If
Response.Write "<tr>"&Farg&"<td width=""40"" height=""30"" align=""center"">"& arrRows(0, cRows) &"</td>"&_
"<td width=""160"" height=""30"" align=""left""><font color=""000000"" face=""Verdana"" size=""2"">"& Left(arrRows(1, cRows),16) &"</td>"&_
"<td width=""240"" height=""30"" align=""left""><font color=""000000"" face=""Verdana"" size=""2"">"& arrRows(2, cRows) &" - "& arrRows(3, cRows) &"</td>"&_
"<td width=""70"" height=""30"" align=""center""><font color=""000000"" face=""Verdana"" size=""2""><input type=""radio"" value=""R1"" name="& arrRows(4, cRows) &">"& arrRows(5, cRows) &"</td>" &_
"<td width=""70"" height=""30"" align=""center""><font color=""000000"" face=""Verdana"" size=""2""><input type=""radio"" value=""RX"" name="& arrRows(4, cRows) &">"& arrRows(6, cRows) &"</td>" &_
"<td width=""70"" height=""30"" align=""center""><font color=""000000"" face=""Verdana"" size=""2""><input type=""radio"" value=""R2"" name="& arrRows(4, cRows) &">"& arrRows(7, cRows) &"</td>" &_
"<input type=""hidden"" size=""3"" name=""GameID"" value="& arrRows(4, cRows) &"></tr>"
Next
Response.Write "<tr><td width=""40"" height=""30"" align=""center""> </td>"&_
"<td width=""160"" height=""30""> </td>"&_
"<td width=""240"" height=""30""> </td>"&_
"<td width=""70"" height=""30""> </td>"&_
"<td width=""70"" height=""30""> </td>"&_
"<td width=""70"" height=""30""> </td></tr>"
Response.write "</table>"
End If
Response.Write "<form action=""tippa_odds_ny_add.asp""><input type=""submit"" value=""tippa"" name=""B1"">"
Response.Write "</form>"
Call dbDisConnect()
%>
Sv: Skicka till databasen
..men som svar på frågan skulle jag säga att problemet ligger i att formuläret inte finns med från början utan skapas på några av dom sista raderna och att alla fält då inte får korrekta värden.
GameID - tilldelas utanför formuläret
UserID - tilldelas inte alls