|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Syntax Error (I think ) --->Please try to help
Can you please find out where is the error .I'm stuck in this simple
error which I don't know ! emailaddress = Request.Form("email") sql= "INSERT INTO mlist (id,email) VALUES ('','"& emailaddress "')" |
|
#2
|
|||
|
|||
|
you're probably getting an error on the insert for the ID if it's not allowing nulls. If you have an autoincrementing number as the primary key do this
sql= "INSERT INTO mlist (email) VALUES ('"& emailaddress "')" |
|
#3
|
|||
|
|||
|
Hi unatratnag,
Thanks for replying , I tried using your approach but it didn't work .Yes ,the id is an auto number.My aim was to copy the entries of the form to a table in the database.I hope anyone can help . Thanks in advance, |
|
#4
|
||||
|
||||
|
dont put the id in the query if its an auto number.
|
|
#5
|
|||
|
|||
|
I tried not putting it but the problem is still there .Is there any syntax error in the expression :
sql= "INSERT INTO mlist (email) VALUES ('"& emailaddress "')" knowing that 'emailaddress' is a VBscript variable carring the form input . |
|
#6
|
||||
|
||||
|
i didn't see it at first, but, yes you dont have an ampersand "&" after emailaddress
|
|
#7
|
|||
|
|||
|
Try a debug response.write emailaddress to see if there is a value. If emailaddress is empty for some reason you'll get a syntax error.
|
|
#8
|
|||
|
|||
|
Hi Doug G,
I didn't know how to debug the code.What program can I use? OH god,I'm really stuck in this problem.Can anybody refer me to examples where inputs of a from are sent to mysql database?That's What I need . Thanks, |
|
#9
|
|||
|
|||
|
First, as roninblade said, edit this line to
sql= "INSERT INTO mlist (email) VALUES ('"& emailaddress & "')" Right above this line for debugging you can add a line: response.write "email address variable is: " & emailaddress & "<br />" This will show the value for email address in your browser and you can then see if it's right or not. |
|
#10
|
|||
|
|||
|
Thank you roninblade
Thank you Doug G, Thank you all .My code worked finally .Forgive me if I asked too much .I'm learning .We're all learning. |
|
#11
|
|||
|
|||
|
ouch... left out of the thank yous again.. that hurts
debugging is not a program or anything.. Just before you're getting errors do stuff like, print out the line to see if it's what you think it is. as for constructing SQL strings.... If you're knew, the first thing to learn is SQL when working with a database. If you try and work strait from ASP you'll confuse yourself. Get your lines working first in the DB command prompt. If you know you can't insert a value for a primary key because it's autoincremeint, you should open up your mysql and run queries till you figure out a working query, in this case Code:
INSERT INTO mlist (email) VALUES ('test@devshed.com')
that works perfect. THe next step would be to make this an asp string. And you know how to concatenate strings right? with an &. So what value in this line needs to be dynamic? the email address of course. so pull that out and stick a variable in, easiest thing to do is to just do this Code:
starting SQL line
INSERT INTO mlist (email) VALUES ('test@devshed.com')
add surrounding quotes first
"INSERT INTO mlist (email) VALUES ('test@devshed.com')"
delete variable(s)
"INSERT INTO mlist (email) VALUES ('')"
add our string closings around variables
"INSERT INTO mlist (email) VALUES ('" "')"
add ampersands in
"INSERT INTO mlist (email) VALUES ('" & & "')"
add variable
"INSERT INTO mlist (email) VALUES ('" & emailvariable & "')"
good luck with getting the hang of it. |
|
#12
|
|||
|
|||
|
Thank you too unatratnag,
It's really a great work.You gave me a really good tutorial .I'm a beginner who is trying to explore the beauty of interactive languages and their relation with database.I'm now building my knowledge to be ready for the future . Thank you all ... |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > Syntax Error (I think ) --->Please try to help |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|