Ciao a tutti,
sto creando un sito ecommerce.
Praticamente quando vado a compilare la form per inserire il mio prodotto nell'area mministratore mi genera l'errore Errore di sintassi nell'istruzione INSERT INTO
chi mi può aiutare?
grazie
Ciao a tutti,
sto creando un sito ecommerce.
Praticamente quando vado a compilare la form per inserire il mio prodotto nell'area mministratore mi genera l'errore Errore di sintassi nell'istruzione INSERT INTO
chi mi può aiutare?
grazie
E si vede che nella tua query ci sta qualche apice di troppo nelle stringhe che cerchi di inserire oppure qualche parametro numerico mancante.
Così ad occhio, senza vedere una riga del tuo codice del tuo E-Commerce, è quello che si riesce a desumere.
ti posto il codice:
<%
if Session("loggedon") <> "virtualstore" then response.end
Dim sSQL,rs,alldata,success,cnn,rowcounter,allsections ,alloptions,errmsg,shipType,iPounds,iOunces,prodop tions,stockManage,adminUnits,subCats,lasttsid,dore fresh
success=true
Set rs = Server.CreateObject("ADODB.RecordSet")
Set cnn=Server.CreateObject("ADODB.Connection")
cnn.open sDSN
sSQL = "SELECT adminShipping,adminStockManage,adminUnits,adminSub Cats FROM admin"
rs.Open sSQL,cnn,0,1
shipType = Int(rs("adminShipping"))
stockManage = Int(rs("adminStockManage"))
adminUnits = Int(rs("adminUnits"))
subCats=(Int(rs("adminSubCats"))=1)
rs.Close
dorefresh=FALSE
if request.form("posted")="1" then
if request.form("act")="delete" then
sSQL = "DELETE FROM cpnAssign WHERE cpaType=2 AND cpaAssignment='"&request.form("id")&"'"
cnn.Execute(sSQL)
sSQL = "DELETE FROM products WHERE pID='" & request.form("id")&"'"
cnn.Execute(sSQL)
sSQL = "DELETE FROM prodOptions WHERE poProdID='" & request.form("id")&"'"
cnn.Execute(sSQL)
dorefresh=TRUE
elseif request.form("act")="domodify" then
if Trim(Request.Form("newid")) <> Trim(Request.Form("id")) then
sSQL = "SELECT * FROM products WHERE pID='"&Trim(request.form("newID"))&"'"
rs.Open sSQL,cnn,0,1
success = rs.EOF
rs.Close
end if
if success then
sSQL = "UPDATE products SET " & _
"pID='"& Trim(Request.Form("newid")) &"', " & _
"pName='"& Replace(Trim(Request.Form("pName")),"'","''") &"', " & _
"pPrice2='"& Replace(Trim(Request.Form("pPrice2")),"'","''") &"', " & _
"pPrice3='"& Replace(Trim(Request.Form("pPrice3")),"'","''") &"', " & _
"pPrice4='"& Replace(Trim(Request.Form("pPrice4")),"'","''") &"', " & _
"pPrice5='"& Replace(Trim(Request.Form("pPrice5")),"'","''") &"', " & _
"pPrice6='"& Replace(Trim(Request.Form("pPrice6")),"'","''") &"', " & _
"pPrice7='"& Replace(Trim(Request.Form("pPrice7")),"'","''") &"', " & _
"pPrice8='"& Replace(Trim(Request.Form("pPrice8")),"'","''") &"', " & _
"pPrice9='"& Replace(Trim(Request.Form("pPrice9")),"'","''") &"', " & _
"pPrice10='"& Replace(Trim(Request.Form("pPrice10")),"'","''") &"', " & _
"pmisura1='"& Replace(Trim(Request.Form("pmisura1")),"'","''") &"', " & _
"pmisura2='"& Replace(Trim(Request.Form("pmisura2")),"'","''") &"', " & _
"pmisura3='"& Replace(Trim(Request.Form("pmisura3")),"'","''") &"', " & _
"pmisura4='"& Replace(Trim(Request.Form("pmisura4")),"'","''") &"', " & _
"pmisura5='"& Replace(Trim(Request.Form("pmisura5")),"'","''") &"', " & _
"pmisura6='"& Replace(Trim(Request.Form("pmisura6")),"'","''") &"', " & _
"pmisura7='"& Replace(Trim(Request.Form("pmisura7")),"'","''") &"', " & _
"pmisura8='"& Replace(Trim(Request.Form("pmisura8")),"'","''") &"', " & _
"pmisura9='"& Replace(Trim(Request.Form("pmisura9")),"'","''") &"', " & _
"pmisura10='"& Replace(Trim(Request.Form("pmisura10")),"'","''") &"', " & _
"pSection="& Trim(Request.Form("pSection")) &", " & _
"pImage='"& Replace(Trim(Request.Form("pImage")),"'","''") &"', " & _
"pLargeImage='"& Replace(Trim(Request.Form("pLargeImage")),"'","''" ) &"', "
if Trim(Request.Form("pDisplay")) = "ON" then
sSQL = sSQL & "pDisplay=1,"
else
sSQL = sSQL & "pDisplay=0,"
end if
if stockManage<>0 then
sSQL = sSQL & "pInStock=" & Trim(request.form("inStock"))&","
else
if Trim(Request.Form("pSell")) = "ON" then
sSQL = sSQL & "pSell=1,"
else
sSQL = sSQL & "pSell=0,"
end if
end if
if shipType=1 then
if NOT IsNumeric(Trim(request.form("pShipping"))) then
sSQL = sSQL & "pShipping=0,"
else
sSQL = sSQL & "pShipping="&Trim(request.form("pShipping"))&" ,"
end if
if NOT IsNumeric(Trim(request.form("pShipping2"))) then
sSQL = sSQL & "pShipping2=0,"
else
sSQL = sSQL & "pShipping2="&Trim(request.form("pShipping2")) &","
end if
elseif shipType = 2 OR shipType=4 then
if NOT IsNumeric(Trim(request.form("pShipping"))) then
sSQL = sSQL & "pWeight=0,"
else
sSQL = sSQL & "pWeight="&Trim(request.form("pShipping"))&","
end if
elseif shipType = 3 then
sSQL = sSQL & "pWeight="&Trim(request.form("pShipping"))&"."
if Int(Trim(request.form("pShipping2"))) < 10 then sSQL = sSQL & "0"
sSQL = sSQL & Trim(request.form("pShipping2")) & ","
end if
if Trim(Request.Form("pListPrice"))<>"" then
sSQL = sSQL & "pListPrice="& Trim(Request.Form("pListPrice")) &","
else
sSQL = sSQL & "pListPrice=0,"
end if
sSQL = sSQL & "pPrice="& Trim(Request.Form("pPrice")) &" " & _
"WHERE pID='"&Request.Form("id")&"'"
on error resume next
cnn.Execute(sSQL)
sSQL = "DELETE FROM prodOptions WHERE poProdID='"&Request.Form("id")&"'"
cnn.Execute(sSQL)
for rowcounter=0 to maxprodopts-1
if request.form("pOption"&rowcounter)<>"" AND request.form("pOption"&rowcounter)<>0 then
sSQL = "INSERT INTO prodOptions (poProdID,poOptionGroup) VALUES ('"&Request.Form("newid")&"',"&request.form("pOpti on"&rowcounter)&")"
cnn.Execute(sSQL)
end if
next
if err.number<>0 then
success=false
errmsg = "There was an error writing to the database.
"
if err.number = -2147467259 then
errmsg = errmsg & "Your database does not have write permissions."
else
errmsg = errmsg & err.description
end if
else
dorefresh=TRUE
end if
on error goto 0
else
errmsg = "Sorry, that product reference is already in use. Please use your browser back button to return and correct the problem."
end if
elseif request.form("act")="doaddnew" then
sSQL = "SELECT * FROM products WHERE pID='"&Trim(request.form("newID"))&"'"
rs.Open sSQL,cnn,0,1
success = rs.EOF
rs.Close
if success then
sSQL = "INSERT INTO products (pID,pName,pSection,pImage,pLargeImage,pPrice,pPri ce2,pPrice3,pPrice4,pPrice5,pPrice6,pPrice7,pPrice 8,pPrice9,pPrice10,pmisura1,pmisura2,pmisura3,pmis ura4,pmisura5,pmisura6,pmisura7,pmisura8,pmisura9, pmisura10"
if shipType=1 then sSQL = sSQL & "pShipping,pShipping2,"
sSQL = sSQL & "pDisplay,"
if stockManage<>0 then
sSQL = sSQL & "pInStock,"
else
sSQL = sSQL & "pSell,"
end if
sSQL = sSQL & "pWeight) VALUES (" & _
"'"&Trim(request.form("newID"))&"'," & _
"'"&replace(request.form("pName"),"'","''")&"' ," & _
request.form("pSection")&"," & _
"'"&replace(request.form("pImage"),"'","''")&" '," & _
"'"&replace(request.form("pLargeImage"),"'","''")& "'," & _
"'"&replace(request.form("pmisura1"),"'","''")&"', " & _
Trim(request.form("pPrice"))&","
if Trim(request.form("pListPrice"))<>"" then
sSQL = sSQL & Trim(request.form("pListPrice")) & ","
else
sSQL = sSQL & "0,"
end if
Trim(request.form("pPrice2"))&","
if Trim(request.form("pListPrice"))<>"" then
sSQL = sSQL & Trim(request.form("pListPrice")) & ","
else
sSQL = sSQL & "0,"
end if
Trim(request.form("pPrice3"))&","
if Trim(request.form("pListPrice"))<>"" then
sSQL = sSQL & Trim(request.form("pListPrice")) & ","
else
sSQL = sSQL & "0,"
end if
Trim(request.form("pPrice4"))&","
if Trim(request.form("pListPrice"))<>"" then
sSQL = sSQL & Trim(request.form("pListPrice")) & ","
else
sSQL = sSQL & "0,"
end if
Trim(request.form("pPrice5"))&","
if Trim(request.form("pListPrice"))<>"" then
sSQL = sSQL & Trim(request.form("pListPrice")) & ","
else
sSQL = sSQL & "0,"
end if
Trim(request.form("pPrice6"))&","
if Trim(request.form("pListPrice"))<>"" then
sSQL = sSQL & Trim(request.form("pListPrice")) & ","
else
sSQL = sSQL & "0,"
end if
Trim(request.form("pPrice7"))&","
if Trim(request.form("pListPrice"))<>"" then
sSQL = sSQL & Trim(request.form("pListPrice")) & ","
else
sSQL = sSQL & "0,"
end if
Trim(request.form("pPrice8"))&","
if Trim(request.form("pListPrice"))<>"" then
sSQL = sSQL & Trim(request.form("pListPrice")) & ","
else
sSQL = sSQL & "0,"
end if
Trim(request.form("pPrice9"))&","
if Trim(request.form("pListPrice"))<>"" then
sSQL = sSQL & Trim(request.form("pListPrice")) & ","
else
sSQL = sSQL & "0,"
end if
Trim(request.form("pPrice10"))&","
if Trim(request.form("pListPrice"))<>"" then
sSQL = sSQL & Trim(request.form("pListPrice")) & ","
else
sSQL = sSQL & "0,"
end if
if shipType=1 then
if NOT IsNumeric(Trim(request.form("pShipping"))) then
sSQL = sSQL & "0,"
else
sSQL = sSQL & Trim(request.form("pShipping"))&","
end if
if NOT IsNumeric(Trim(request.form("pShipping2"))) then
sSQL = sSQL & "0,"
else
sSQL = sSQL & Trim(request.form("pShipping2"))&","
end if
end if
if Trim(Request.Form("pDisplay")) = "ON" then
sSQL = sSQL & "1,"
else
sSQL = sSQL & "0,"
end if
if stockManage<>0 then
sSQL = sSQL & Trim(request.form("inStock"))&","
else
if Trim(Request.Form("pSell")) = "ON" then
sSQL = sSQL & "1,"
else
sSQL = sSQL & "0,"
end if
end if
if shipType <= 1 OR NOT IsNumeric(Trim(request.form("pShipping"))) then
sSQL = sSQL & "0"
elseif shipType = 2 OR shipType=4 then
sSQL = sSQL & Trim(request.form("pShipping"))&""
else
sSQL = sSQL & Trim(request.form("pShipping"))&"."
if Int(Trim(request.form("pShipping2"))) < 10 then sSQL = sSQL & "0"
sSQL = sSQL & Trim(request.form("pShipping2"))
end if
sSQL = sSQL & ")"
on error resume next
cnn.Execute(sSQL)
for rowcounter=0 to maxprodopts-1
if request.form("pOption"&rowcounter)<>"" AND request.form("pOption"&rowcounter)<>0 then
sSQL = "INSERT INTO prodOptions (poProdID,poOptionGroup) VALUES ('"&Request.Form("newid")&"',"&request.form("pOpti on"&rowcounter)&")"
cnn.Execute(sSQL)
end if
next
if err.number<>0 then
success=false
errmsg = "There was an error writing to the database.
"
if err.number = -2147467259 then
errmsg = errmsg & "Your database does not have write permissions."
else
errmsg = errmsg & err.description
end if
else
dorefresh=TRUE
end if
on error goto 0
else
errmsg = "Sorry, that product reference is already in use. Please use your browser back button to return and correct the problem."
end if
elseif request.form("act")="dodiscounts" then
sSQL = "INSERT INTO cpnAssign (cpaCpnID,cpaType,cpaAssignment) VALUES ("&request.form("assdisc")&",2,'"&request.form("id ")&"')"
cnn.Execute(sSQL)
dorefresh=TRUE
elseif request.form("act")="deletedisc" then
sSQL = "DELETE FROM cpnAssign WHERE cpaID="&request.form("id")
cnn.Execute(sSQL)
dorefresh=TRUE
end if
if request.form("act")="modify" OR request.form("act")="addnew" then
sSQL = "SELECT optGrpID, optGrpWorkingName FROM optionGroup ORDER BY optGrpWorkingName"
rs.Open sSQL,cnn,0,1
if NOT rs.EOF then alloptions=rs.getrows
rs.Close
if request.form("act")="modify" then
sSQL = "SELECT poID, poOptionGroup FROM prodOptions WHERE poProdID='"&Trim(Request.Form("id"))&"'"
rs.Open sSQL,cnn,0,1
if NOT rs.EOF then prodoptions=rs.getrows
rs.Close
end if
end if
end if
if dorefresh then
response.write "<meta http-equiv=""refresh"" content=""3; url=adminprods.asp"
if Trim(request.form("ts"))<>"" then
response.write "?ts=" & Trim(request.form("ts"))
elseif Trim(request.form("tt"))<>"" then
response.write "?tt=" & Trim(request.form("tt"))
end if
response.write """>"
end if
%>
Un botto di codice.
Posso solo dirti che i valori numerici che vanno salvati in campi di tipo numerico non vanno compresi tra apici singoli.
e si scusa.
provo a vedere la tua indicazione
grazie
niente da fare non trovo la soluzione
Fai una response.write della sql e subito dopo un response.flush e postaci cosa appare.