Wrox Programmer Forums
|
ASP Forms As of Oct 5, 2005, this forum is now locked. Please use "Classic ASP beginner" at http://p2p.wrox.com/forum.asp?FORUM_ID=54 or "Classic ASP Professional" http://p2p.wrox.com/forum.asp?FORUM_ID=56 instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Forms section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 24th, 2004, 09:52 AM
Registered User
 
Join Date: Jan 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Compliation error, can some1 help

This is my code for my web page but when iam compile it i get an error code:

Microsoft VBScript compilation error '800a03ee'

Expected ')'

/year4/MMT4-77/Adminsite/AddCD.asp, line 50

VALUES (" & Artist_name & "','" & Album_name & "','" & Producer & "','" & Record_label &
---------------------------^
Can some1 tell me why this is happening please. The page is supposed to take the information from the form and insert it into my database.

<%
'===================
'REQUEST FORM VARIABLES
'===================

Dim Artist_name, Album_name, Producer, Record_label, Track_1, Track_2, Track_3, Track_4, Track_5, ImagePath_1, ImagePath_2

Artist Name = Request.Form("Artist_name")
Album Name = Request.Form("Album_name")
Producer = Request.Form("Producer")
Record_Label = Request.Form("Record_label")
Track 1 = Request.Form("Track_1")
Track 2 = Request.Form("Track_2")
Track 3 = Request.Form("Track_3")
Track 4 = Request.Form("Track_4")
Track 5 = Request.Form("Track_5")
ImagePath 1 = Request.Form("ImagePath_1")
ImagePath 2 = Request.Form("ImagePath_2")

dbPath = Server.mapPath("online_music.mdb")

set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open dbPath

set rs = Server.CreateObject("ADODB.Recordset")

strSQL = "SELECT * FROM CD where Artist Name='" & Artist_name & "'"

rs.Open strSQL, conn

IF NOT rs.EOF THEN
    'Response.Write("User exists go away")
    Response.Redirect("ErrorPage.htm")
ELSE
    'Response.Redirect("ErrorPage.htm")
END IF


'Do While Not rs.EOF
' response.write(rs("Name") & " " & rs("Surname") & "<br>")
' rs.movenext
'Loop

rs.Close



strSQLInsert = "INSERT INTO CD (Artist Name,Album Name,Producer,Record Label,Track 1,Track 2,Track 3,Track 4,Track 5,ImagePath1,ImagePath2) " & _
VALUES (" & Artist_name & "','" & Album_name & "','" & Producer & "','" & Record_label & "','" & Track_1 & "','" & Track_2 & "','" & Track_3 & "','" & Track_4 & "','" & Track_5 & "','" & ImagePath_1 & "','" & ImagePath_2 & "')"


Response.Write(strSQL & "<br>")


Response.Write(strSQLInsert)

' INSERT NEW DATA TO DB ==
rs.Open strSQLInsert, conn
' ========================

' = SHOW NEW DETAILS =====
rs.Open strSQL, conn
Do While Not rs.EOF
    response.write(rs("Artist Name") & " " & rs("Album Name") & "<br>")
    rs.movenext
Loop
rs.Close
' ========================

conn.close
'Response.Redirect("thankyou.htm")

%>
<html>
<head>
<title>Add_CD</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>

<div id="Layer1" style="position:absolute; left:103px; top:64px; width:690px; height:484px; z-index:1">
  <form name="form1" method="post" action="">
    <label></label>
    <table width="75%" border="0">
      <tr>
        <td><strong>
          <label>Artist Name</label>
          </strong></td>
        <td><input type="text" name="Artist_name" size="20"></td>
      </tr>
      <tr>
        <td><strong>Album
          Name </strong></td>
        <td><input type="text" name="Album_name" size="20"></td>
      </tr>
      <tr>
        <td><strong>Producer
          </strong></td>
        <td><input type="text" name="Producer" size="20"></td>
      </tr>
      <tr>
        <td><strong>Record
          label </strong></td>
        <td><input type="text" name="Record_label" size="20"></td>
      </tr>
      <tr>
        <td><strong>Track
          1</strong></td>
        <td><input type="text" name="Track_1" size="20"></td>
      </tr>
      <tr>
        <td><strong>Track
          2</strong></td>
        <td><input type="text" name="Track_2" size="20"></td>
      </tr>
      <tr>
        <td><strong>Track
          3</strong></td>
        <td><input type="text" name="Track_3" size="20"></td>
      </tr>
      <tr>
        <td><strong>Track
          4</strong></td>
        <td><input name="Track_4" type="text" id="Track_4" size="20"></td>
      </tr>
      <tr>
        <td><strong>Track
          5</strong></td>
        <td><input name="Track_5" type="text" id="Track_5" size="20"></td>
      </tr>
      <tr>
        <td><strong>Front
          Image Path</strong></td>
        <td><input type="text" name="ImagePath_1" size="20"></td>
      </tr>
      <tr>
        <td height="24"><strong>Back
          Image Path</strong></td>
        <td><input name="ImagePath_2" type="text" id="ImagePath_2" size="20"></td>
      </tr>
    </table>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp; </p>
    <p>&nbsp; </p>
  </form>
</div>
<div id="Layer2" style="position:absolute; left:303px; top:382px; width:132px; height:29px; z-index:2">
  <form name="form2" method="post" action="">
    <input type="submit" name="Submit" value="Submit">
    <input type="reset" name="Reset" value="Reset">
  </form>
</div>
</body>
</html>

 
Old January 24th, 2004, 12:11 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

It looks like you're not dealing with string starts and ends:
Code:
strSQLInsert = "INSERT INTO CD (Artist Name,Album Name,Producer,Record Label,Track 1,Track 2,Track 3,Track 4,Track 5,ImagePath1,ImagePath2) " & _ 
VALUES
As you can see, the first line ends the string and then uses the underscore to concatenate the next line to it. However, the next line doesn't start with a ". Changing it to:
Code:
strSQLInsert = "INSERT INTO CD (Artist Name,Album Name,Producer,Record Label,Track 1,Track 2,Track 3,Track 4,Track 5,ImagePath1,ImagePath2) " & _ 
"VALUES
should do the trick.

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old January 26th, 2004, 08:22 AM
Registered User
 
Join Date: Jan 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks Imar it did do the trick but now i have a new error.
I says i have a syntax error missing operator error code 80040e14.
on this line, it supposed to check if the album already exist if so
then it should open an error page for now
Here the code.

Dim Artist_name, Album_name, Producer, Record_label, Track_1, Track_2, Track_3, Track_4, Track_5, ImagePath_1, ImagePath_2

Artist_Name = Request.Form("Artist_name")
Album_Name = Request.Form("Album_name")
Producer = Request.Form("Producer")
Record_Label = Request.Form("Record_label")
Track_1 = Request.Form("Track_1")
Track_2 = Request.Form("Track_2")
Track_3 = Request.Form("Track_3")
Track_4 = Request.Form("Track_4")
Track_5 = Request.Form("Track_5")
ImagePath_1 = Request.Form("ImagePath_1")
ImagePath_2 = Request.Form("ImagePath_2")

dbPath = Server.mapPath("online_music.mdb")

set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open dbPath

set rs = Server.CreateObject("ADODB.Recordset")

strSQL = "SELECT * FROM CD WHERE Album_Name=" & Album_name & "'" (THE PROBLEM IS ON THIS LINE)

rs.Open strSQL, conn

IF NOT rs.EOF THEN
    'Response.Write("User exists go away")
    Response.Redirect("ErrorPage.htm")
ELSE
    'Response.Redirect("ErrorPage.htm")
END IF


I have used this code for a previous project it
seemed to have worked then. Please take into account that iam a uni student and have only been doing ASP for 6 months.

thank you

 
Old January 26th, 2004, 11:16 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi,

I think the error is caused by the fact that Album_Name is a string type in the database. String types need to be enclosed in ' characters when you send them to the database:
Code:
strSQL = "SELECT * FROM CD WHERE Album_Name='" & Album_name & "'"
The easiest way to debug these kind of problems is to write the SQL statement to the browser using Response.Write(strSQL). Then copy and paste the statement in your database's query analyzer. In most cases, you'll get an informative error message indicating the problem.

CHeers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old February 20th, 2004, 11:58 AM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 171
Thanks: 0
Thanked 1 Time in 1 Post
Default

Imar is right. You are not enclosing your value in apostrophes. You have a closing apostrophe for Album_Name but not an opening one.

 
Old February 20th, 2004, 12:03 PM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 171
Thanks: 0
Thanked 1 Time in 1 Post
Default

One more thing. If you have fields with a space in the field name you may have problems. I know with a CSV file you must enclose those field names in [] brackets. Not sure about here though. I would recommend removing any spaces in both field names and variables. Originally you showed spaces in your variables that you had defined above. Not sure if this is the case any more.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert Query Error & Run-Time Error 3022 DavidWE Access 1 July 31st, 2008 11:17 AM
Ch 4: Parse error: syntax error, unexpected T_SL hanizar77 BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 0 June 23rd, 2008 09:17 PM
Parse error: syntax error, unexpected T_STRING ginost7 Beginning PHP 1 November 9th, 2007 02:51 AM
VB Error: Syntax Error or Access Violation codehappy VB How-To 7 October 3rd, 2007 05:41 PM
Java Compliation Error !! Stephen Lam Java Databases 1 April 13th, 2005 09:19 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.