Form Issue

Unterminated string constant Error

Page 1 of 1

7 Replies - 1074 Views - Last Post: 24 December 2008 - 07:44 AM Rate Topic: -----

#1 jjsaw5  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 92
  • View blog
  • Posts: 3,063
  • Joined: 04-January 08

Form Issue

Posted 23 December 2008 - 10:34 AM

I'm playing around with a form for my dads when site. Basically it is just a player information form. I am trying to have the information put into an access database but as you can see below I am running into some issues.


***I moved my own post and changed it around a little. :crazy: ***


I'm not really sure about the error i am getting. (Bottom of next post)

Is This A Good Question/Topic? 0
  • +

Replies To: Form Issue

#2 jjsaw5  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 92
  • View blog
  • Posts: 3,063
  • Joined: 04-January 08

Re: Form Issue

Posted 23 December 2008 - 11:21 AM

Here is my form so far.



<%@ Language=VBScript %>
<%
strConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="& Server.MapPath("transit.mdb") &";Persist Security Info=False"



%>
<HTML>
<HEAD>
<title>Player Form</title>
<script language=javascript>
  function check(oForm){
	if(oForm.name.value==""){
	  alert("Please enter your name");
	  oForm.name.focus();
	  return false;
	}

	if((oForm.phone.value=="") && (oForm.interest.value=="") && (oForm.origin.value=="") && (oForm.destination.value=="")){
	  alert("Please enter fill out all the feilds");
	  oForm.phone.focus();
	  return false;
	}
  }
</script>
</HEAD>
<BODY onload="document.frmplayer.name.focus();">
<form name=frmplayer action="addInfo.asp" onsubmit="return check(this);">
<h2><font color=darkblue></font>Player Information Form</h2>
<h3><font color=darkblue>Back to <a href="/depts/bisd/internal/transit/transit.asp">Home Page</a></font></h3>

<br>
<table border=1>
 <td><th bgcolor=lightblue style=font-size:12pt;>Name (Last, First)<td><input type=text style="background-color:#d3d3d3;" name=Name size=25></td></th></tr></td>
 <td><th bgcolor=lightblue style=font-size:12pt;>Address<td><input type=text style="background-color:#d3d3d3;" name=Address size=50></td></th></tr></td>
 <td><th bgcolor=lightblue style=font-size:12pt;>Home Phone <td><input type=text style="background-color:#d3d3d3;" name=Home_Phone size=10></td></th></tr></td>
 <td><th bgcolor=lightblue style=font-size:12pt;>Cell Phone<td><input type=text style="background-color:#d3d3d3;" name=Cell_Phone size=10></td></tr></th></tr>
  <td><th bgcolor=lightblue style=font-size:12pt;>EMail  <td><input type=text style="background-color:#d3d3d3;" name=EMail size=10></td></tr></th></tr>
 <td><th bgcolor=lightblue style=font-size:12pt;>Height  <td><input type=text style="background-color:#d3d3d3;" name=Height size=10></td></tr></th></tr>
 <td><th bgcolor=lightblue style=font-size:12pt;>Weight  <td><input type=text style="background-color:#d3d3d3;" name=Weight size=10></td></tr></th></tr>
 <td><th bgcolor=lightblue style=font-size:12pt;>Bats   <td style="border-left: solid 0px; border-bottom: solid 0px; border-top: solid 0px; border-right: solid 0px;">
	   <select name="Bats">
		 <option value="">Choose One
		 <option value="Passenger">Right
		 <option value="Driver">Left
		 <option value="Either">Both
	   </select> 
	</td> </tr></th></tr>
 <td><th bgcolor=lightblue style=font-size:12pt;>Throws  <td style="border-left: solid 0px; border-bottom: solid 0px; border-top: solid 0px; border-right: solid 0px;">
	   <select name="Throws">
		 <option value="">Choose One
		 <option value="Passenger">Right
		 <option value="Driver">Left
		 <option value="Either">Both
	   </select> 
	</td> </tr></th></tr>
 <td><th bgcolor=lightblue style=font-size:12pt;>Primary Position<td><input type=text style="background-color:#d3d3d3;" name=Postion_Primary size=15></td></tr></th></tr>
 <td><th bgcolor=lightblue style=font-size:12pt;>Secondary Position<td><input type=text style="background-color:#d3d3d3;" name=Postion_Secondary size=15></td></tr></th></tr>
 <td><th bgcolor=lightblue style=font-size:12pt;>Uniform Number  <td><input type=text style="background-color:#d3d3d3;" name=Uniform_Number size=10></td></tr></th></tr>
 <td><th bgcolor=lightblue style=font-size:12pt;>High School  <td><input type=text style="background-color:#d3d3d3;" name=High_School size=50></td></tr></th></tr>
 <td><th bgcolor=lightblue style=font-size:12pt;>Graduation Year  <td><input type=text style="background-color:#d3d3d3;" name=Graduation_year size=10></td></tr></th></tr>
 <td><th bgcolor=lightblue style=font-size:12pt;>GPA  <td><input type=text style="background-color:#d3d3d3;" name=GPA size=10></td></tr></th></tr>
 <td><th bgcolor=lightblue style=font-size:12pt;>SAT Score<td><input type=text style="background-color:#d3d3d3;" name=SAT_Score size=10></td></tr></th></tr>
 <td><th bgcolor=lightblue style=font-size:12pt;>ACT Score  <td><input type=text style="background-color:#d3d3d3;" name=ACT_Score size=10></td></tr></th></tr>
 <tr>
 <td colspan=16 align=center valign=><br><input style="font-weight:bold;width:300px" type=submit value="Submit Form" id=submit1 name=submit1><br><br></td>


 
</table>
</form>
</BODY>
</HTML>



and here is what i have form submitting the information..

<%@ Language=VBScript %>
<%
Response.Buffer = True

strConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="& Server.MapPath("player.mdb") &";Persist Security Info=False"
set conn = Server.CreateObject("ADODB.Connection")
conn.open strConnectionString


Name = request("Name")
Address = request("Address")
Home_Phone = request("Home_Phone")
Cell_Phone = request("Cell_Phone")
EMail = request("EMail")
Height = request("Height")
Weight = request("Weight")
Bats = request("Bats")
Throws = request("Throws")
Position_Primary = request("Position_Primary")
Position_Secondary = request("Position_Secondary")
Uniform_Number = request("Uniform_Number")
High_School = request("High_School")
Graduation_year = request("Graduation_year")
GPA = request("GPA")
SAT_Score = request("SAT_Score")
ACT_Score = request("ACT_Score")

sql = "INSERT INTO tblplayer (Name, Address, Home_Phone, Cell_Phone, EMail, Height, Weight, Bats, Throws, Position_Primary, Position_Secondary, Uniform_Number, High_School, Graduation_year, GPA, SAT_Score, ACT_Score) " 
sql = sql & "VALUES ('" & Name & "', '" & Address & "', '" & Home_Phone & "', '" & Cell_Phone & "', '" & EMail & "', '" & Height & "', '" & Weight & "', '" & Bats & "', '" & Throws & "', '" & Position_Primary & "', '" & Position_Secondary & "', '" & Uniform_Number & "', '" & High_School & "', '" & Graduation_year & "',, '" & GPA & "', '" & SAT_Score & "','" & ACT_Score & "')
conn.Execute(sql)

Response.Redirect "playerform.asp"
%>




I'm getting the following error when i try to submit the form.

Error Type:
Microsoft VBScript compilation (0x800A0409)
Unterminated string constant
addInfo.asp, line 29, column 377

Was This Post Helpful? 0
  • +
  • -

#3 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1659
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Form Issue

Posted 23 December 2008 - 01:35 PM

I believe the problem is with this line

sql = sql & "VALUES ('" & Name & "', '" & Address & "', '" & Home_Phone & "', '" & Cell_Phone & "', '" & EMail & "', '" & Height & "', '" & Weight & "', '" & Bats & "', '" & Throws & "', '" & Position_Primary & "', '" & Position_Secondary & "', '" & Uniform_Number & "', '" & High_School & "', '" & Graduation_year & "',, '" & GPA & "', '" & SAT_Score & "','" & ACT_Score & "')



You dont have a closing quote at the end of the statement, and you have a double comma in it as well. Try this and see if it gets rid of your error

sql = sql & "VALUES ('" & Name & "', '" & Address & "', '" & Home_Phone & "', '" & Cell_Phone & "', '" & EMail & "', '" & Height & "', '" & Weight & "', '" & Bats & "', '" & Throws & "', '" & Position_Primary & "', '" & Position_Secondary & "', '" & Uniform_Number & "', '" & High_School & "', '" & Graduation_year & "', '" & GPA & "', '" & SAT_Score & "','" & ACT_Score & "')"


Was This Post Helpful? 1
  • +
  • -

#4 jjsaw5  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 92
  • View blog
  • Posts: 3,063
  • Joined: 04-January 08

Re: Form Issue

Posted 24 December 2008 - 06:04 AM

That fixed the previous error, now when I try to submit the form i am getting a "Data type mismatch in criteria expression" error at line 30 which is the

conn.Execute(sql)
line
Was This Post Helpful? 0
  • +
  • -

#5 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1659
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Form Issue

Posted 24 December 2008 - 07:10 AM

That sounds as if you're trying to pass a string value to an INT value, of the other way around. Are there any fields in your database that are int values that have single quotes around them in your insert query? Such as Height, Weight, Uniform_Number or any of those?
Was This Post Helpful? 0
  • +
  • -

#6 jjsaw5  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 92
  • View blog
  • Posts: 3,063
  • Joined: 04-January 08

Re: Form Issue

Posted 24 December 2008 - 07:38 AM

Got it working. I for some reason had some of my database feilds set up incorrectly.

thanks for all your help rich!
Was This Post Helpful? 0
  • +
  • -

#7 dklingman  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 33
  • View blog
  • Posts: 263
  • Joined: 23-December 08

Re: Form Issue

Posted 24 December 2008 - 07:41 AM

you don't by chance have a string value that also contains a single quote do you? that may cause a problem as well. i'd suggest making use of the ADODB.Parameter so you don't have to worry about the single quote and then parametrize you insert statement. again only my 2 cent


well nevermind :crazy: :P

This post has been edited by dklingman: 24 December 2008 - 07:42 AM

Was This Post Helpful? 0
  • +
  • -

#8 jjsaw5  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 92
  • View blog
  • Posts: 3,063
  • Joined: 04-January 08

Re: Form Issue

Posted 24 December 2008 - 07:44 AM

View Postdklingman, on 24 Dec, 2008 - 09:41 AM, said:

you don't by chance have a string value that also contains a single quote do you? that may cause a problem as well. i'd suggest making use of the ADODB.Parameter so you don't have to worry about the single quote and then parametrize you insert statement. again only my 2 cent


well nevermind :crazy: :P



I will take all the advice, suggestions, and "2 cents" you want to give.

Thank you for the suggestion i will look into doing that.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1