ttwkeni Posted January 24, 2007 Share Posted January 24, 2007 hi.. i'm reli desperate for help what really happened to my codings? i duno. My asp got so bad. and my submission is due in 8hours time. haven been gotten engh sleep. theres alwy a sytnx error in my asp. which say Syntax error in INSERT INTO statement./Copy/main1.asp, line 21this is my codes<%dim sql, conn, rsset conn=Server.CreateObject("ADODB.Connection")conn.Provider="Microsoft.Jet.OLEDB.4.0"conn.Open(Server.Mappath("fastfood.mdb"))%><html><head><title>User Login</title></head><body><%if Request.Form("userName")="" or Request.Form("add")="" or Request.Form("phone")="" then response.redirect("main.html")else sql="INSERT INTO McUser(userName, phone, add)" sql=sql&"VALUES" sql=sql&" ( ' " & request.form("userName") & " ' , " sql=sql& " ' " & request.form("phone") & " ' , " sql=sql& " ' " & request.form("add") & " ' ) " Session("userName") = request.form("userName") conn.Execute sql, recaffected conn.close response.redirect("order.html")end if%> </body></html>what happen? Link to comment Share on other sites More sharing options...
pulpfiction Posted January 24, 2007 Share Posted January 24, 2007 Error is possibly because of spaces in the preparing sql query....Try this...sql="INSERT INTO McUser(userName, phone, add)"sql=sql& " VALUES "sql=sql& "('" & request.form("userName") & "',"sql=sql& "'" & request.form("phone") & "',"sql=sql& "'" & request.form("add") & "')" Link to comment Share on other sites More sharing options...
ttwkeni Posted January 24, 2007 Author Share Posted January 24, 2007 ok thanz alot. nw problem after problem. .. it's already 3.3am down here... things are working just fine. However, from that codings, when doing registration, nothing went into my data base man. Meaning that i open my fastfood.mdb. nothing is there. when i open the McUser Table. No data nothing. and i wonder y.. - . - Link to comment Share on other sites More sharing options...
pulpfiction Posted January 24, 2007 Share Posted January 24, 2007 problem could be because of the path to database. try giving the direct path, like eg: conn.Open "C:/foldername/fastfood.mdb" Link to comment Share on other sites More sharing options...
ttwkeni Posted January 24, 2007 Author Share Posted January 24, 2007 still no good :< ... when i enter userName=A phone=2 add=A at register screen. It move on to shopping cart. However, when i see fastfood mdb. still cant find any item listed in McUser. it shld be listed userName=A phone=2 add=A in the database rite? but it's just plain piece of table - . - Link to comment Share on other sites More sharing options...
pulpfiction Posted January 24, 2007 Share Posted January 24, 2007 Does it throw ay error? Also check out this pagehttp://www.w3schools.com/ado/ado_add.aspThere is a error handling code example, to check if DB insert permission.... Link to comment Share on other sites More sharing options...
justsomeguy Posted January 25, 2007 Share Posted January 25, 2007 Also get rid of the recaffected variable in the call to conn.execute. Why do you have it there? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now