SitePoint Sponsor

User Tag List

Results 1 to 15 of 15
  1. #1
    SitePoint Guru
    Join Date
    Dec 2000
    Location
    Karachi, Pakistan
    Posts
    913
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    (ASP) - UnExpected End

    Hello,

    I was writing a CMS, but I am stuck on an error when I try to submit a form which adds article to the database.

    Please help me solving this dilemma..

    Here is the code..

    Code:
    <!--#INCLUDE FILE="conn.asp"-->
    <%response.buffer=true%>
    
    <html>
    
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <meta name="GENERATOR" content="Microsoft FrontPage 4.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <title>Add ASP Article :: Dev Echo</title>
    </head>
    
    <body bgcolor="#FFFFFF" topmargin="1" leftmargin="3">
    
    <#include page="conn.asp">
    
    <p><img border="0" src="images/devehco.gif"></p>
    <p>&nbsp;</p>
    <%
    
    category=request.form("txtcategory")
    articletitle=request.form("txtarticletitle")
    author=request.form("txtauthor")
    email=request.form("txtemail")
    desc=request.form("txtdesc")
    article=request.form("txtarticle")
    about=request.form("txtabout")
    pid=request.form("txtpid")
    
    articletitle=replace(articletitle,"'","""")
    author=replace(author,"'","""")
    email=replace(email,"'","""")
    desc=replace(desc,"'","""")
    article=replace(article,"'","""")
    about=replace(about,"'","""")
    
    if category="webdesign" then
    sql="insert into webdesign(title,author,email,desc,article,about,pid) values('" & articletitle & "','" & author & "','" & email & "','" & desc & "','" & article & "','" & about & "','" & pid & "')"
    
    else if category="graphics" then
    sql="insert into gfx(title,author,email,desc,article,about,pid) values('" & articletitle & "','" & author & "','" & email & "','" & desc & "','" & article & "','" & about & "','" & pid & "')"
    
    else if category="misc" then
    sql="insert into misc(title,author,email,desc,article,about,pid) values('" & articletitle & "','" & author & "','" & email & "','" & desc & "','" & article & "','" & about & "','" & pid & "')"
    
    else if category="promotion" then
    sql="insert into promotion(title,author,email,desc,article,about,pid) values('" & articletitle & "','" & author & "','" & email & "','" & desc & "','" & article & "','" & about & "','" & pid & "')"
    
    else if category="programming" then
    sql="insert into programming(title,author,email,desc,article,about,pid) values('" & articletitle & "','" & author & "','" & email & "','" & desc & "','" & article & "','" & about & "','" & pid & "')"
    
    else
    sql="insert into reviews(title,author,email,desc,article,about,pid) values('" & articletitle & "','" & author & "','" & email & "','" & desc & "','" & article & "','" & about & "','" & pid & "')"
    
    set dbrs=dbconn.execute(sql)
    %>
    
    
    <p>&nbsp;</p>
    <p align="center"><font size="2" face="Arial">Thank You for adding an Article in
    our Database. You Article is listed in the Respective Category.<br>
    Please remember your Article ID Number For Future Reference.</font></p>
    <blockquote>
      <p align="left"><font size="2" face="Arial">Regards,<br>
      <b>Administrator</b></font></p>
    </blockquote>
    
    
    </body>
    
    </html>
    The error is on line 58 and the error is

    UnExpected End


    Please help me


    Regards,
    Omair Haroon
    36Host.com - $36/year web hosting [affiliates earn 30%]
    * Affordable Small Business Web Hosting since 2003! *
    "500mb space, 10gb bandwith, 50 pop/ftp accounts, php,
    mysql, pre-installed php scripts, 24/7 support & more...."



  2. #2
    SitePoint Wizard big_al's Avatar
    Join Date
    May 2000
    Location
    Victoria, Australia
    Posts
    1,661
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    ok it's early in the morning, but I can't see an End if anywhere

    Also you have included conn.asp twice

    Hope this helps
    .NET Code Monkey

  3. #3
    SitePoint Evangelist Umair.ms's Avatar
    Join Date
    Sep 2000
    Location
    Lahore, Pakistan
    Posts
    567
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There seems to three errors:
    * No End If is present
    * All Else If should be replaced with Elseif
    * set dbrs=dbconn.execute(sql)
    should be replaced with
    dbconn.execute(sql)

    hope that helps.

    Omair kiya tum ab bhi naraz ho? Mein sirf mazak kar raha thaa...
    TinyPlanet.org
    Discuss and Debate World Events, Politics and Religion.
    Interact and Share your Views with People around the Globe.

  4. #4
    SitePoint Guru
    Join Date
    Dec 2000
    Location
    Karachi, Pakistan
    Posts
    913
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have removed all the errors.. but to no avail..

    I am posting the code here again with the error

    Code:
    <!--#include file="conn.asp"-->
    
    
    <html>
    
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <meta name="GENERATOR" content="Microsoft FrontPage 4.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <title>Add ASP Article :: Dev Echo</title>
    </head>
    
    <body bgcolor="#FFFFFF" topmargin="1" leftmargin="3">
    
    
    
    <p><img border="0" src="images/devehco.gif"></p>
    <p>&nbsp;</p>
    <%
    
    category=request.form("txtcategory")
    articletitle=request.form("txtarticletitle")
    author=request.form("txtauthor")
    email=request.form("txtemail")
    desc=request.form("txtdesc")
    article=request.form("txtarticle")
    about=request.form("txtabout")
    pid=request.form("txtpid")
    
    articletitle=replace(articletitle,"'","""")
    author=replace(author,"'","""")
    email=replace(email,"'","""")
    desc=replace(desc,"'","""")
    article=replace(article,"'","""")
    about=replace(about,"'","""")
    
    if category="webdesign" then
    sql="insert into webdesign(title,author,email,desc,article,about,pid) values('" & articletitle & "','" & author & "','" & email & "','" & desc & "','" & article & "','" & about & "'," & pid & ")"
    
    elseif category="graphics" then
    sql="insert into gfx(title,author,email,desc,article,about,pid) values('" & articletitle & "','" & author & "','" & email & "','" & desc & "','" & article & "','" & about & "','" & pid & "')"
    
    elseif category="misc" then
    sql="insert into misc(title,author,email,desc,article,about,pid) values('" & articletitle & "','" & author & "','" & email & "','" & desc & "','" & article & "','" & about & "','" & pid & "')"
    
    elseif category="promotion" then
    sql="insert into promotion(title,author,email,desc,article,about,pid) values('" & articletitle & "','" & author & "','" & email & "','" & desc & "','" & article & "','" & about & "','" & pid & "')"
    
    elseif category="programming" then
    sql="insert into programming(title,author,email,desc,article,about,pid) values('" & articletitle & "','" & author & "','" & email & "','" & desc & "','" & article & "','" & about & "','" & pid & "')"
    
    else
    sql="insert into reviews(title,author,email,desc,article,about,pid) values('" & articletitle & "','" & author & "','" & email & "','" & desc & "','" & article & "','" & about & "','" & pid & "')"
    
    end if
    
    response.write sql
    dbrs=dbconn.execute(sql)
    
    %>
    
    
    <p>&nbsp;</p>
    <p align="center"><font size="2" face="Arial">Thank You for adding an Article in
    our Database. You Article is listed in the Respective Category.<br>
    Please remember your Article ID Number For Future Reference.</font></p>
    <blockquote>
      <p align="left"><font size="2" face="Arial">Regards,<br>
      <b>Administrator</b></font></p>
    </blockquote>
    
    
    </body>
    
    </html>
    and here is the error :

    Code:
    Microsoft OLE DB Provider for ODBC Drivers error '80040e14' 
    
    [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement. 
    
    /webmin/addarticle2.asp, line 58

    Regards,
    Omair Haroon
    36Host.com - $36/year web hosting [affiliates earn 30%]
    * Affordable Small Business Web Hosting since 2003! *
    "500mb space, 10gb bandwith, 50 pop/ftp accounts, php,
    mysql, pre-installed php scripts, 24/7 support & more...."



  5. #5
    SitePoint Wizard
    Join Date
    Jul 1999
    Location
    Chicago
    Posts
    2,629
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You're already Response.Write'ing the SQL statement, so what does it print out? Apparently, it has a syntax error.

  6. #6
    SitePoint Guru
    Join Date
    Dec 2000
    Location
    Karachi, Pakistan
    Posts
    913
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    insert into webdesign(title,author,email,desc,article,about,pid) values('sdas','sd','as','dasda','ads','sd',2)

    is the output on write'ing the sql

    Any ideas what's the problem ?


    Regards,
    Omair Haroon
    36Host.com - $36/year web hosting [affiliates earn 30%]
    * Affordable Small Business Web Hosting since 2003! *
    "500mb space, 10gb bandwith, 50 pop/ftp accounts, php,
    mysql, pre-installed php scripts, 24/7 support & more...."



  7. #7
    SitePoint Wizard
    Join Date
    Jul 1999
    Location
    Chicago
    Posts
    2,629
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've never seen that sort of syntax. I just tried it on MySQL and it gave an error, so even if it works on your system, it's not widespread. Try this:

    insert into webdesign set title='sdas', author='sd', email='as', desc='dasda', article='ads', about='sd', pid='2';

    I don't know your table structure but you could also use: insert into webdesign values(...);.

  8. #8
    SitePoint Wizard big_al's Avatar
    Join Date
    May 2000
    Location
    Victoria, Australia
    Posts
    1,661
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    if PID is a numerical value then it should be " & PID & " instead of '" & PID & "'.

    '" & PID & "' is telling it that it's inserting a string, not a Numerical value
    .NET Code Monkey

  9. #9
    SitePoint Guru
    Join Date
    Dec 2000
    Location
    Karachi, Pakistan
    Posts
    913
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks big_al,

    But I have been using the the webdesign insert query that have

    Code:
    ' & pid & '
    Any other ideas ?

    Please help
    36Host.com - $36/year web hosting [affiliates earn 30%]
    * Affordable Small Business Web Hosting since 2003! *
    "500mb space, 10gb bandwith, 50 pop/ftp accounts, php,
    mysql, pre-installed php scripts, 24/7 support & more...."



  10. #10
    SitePoint Guru
    Join Date
    Dec 2000
    Location
    Karachi, Pakistan
    Posts
    913
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by DriveSeeker

    Omair kiya tum ab bhi naraz ho? Mein sirf mazak kar raha thaa...
    [offtopic]
    That's Ok. Mein ab naraz nahi hoon.. magar yaar. tum khud soocho.. jab koi banda seekh raha hoo aur aap us ka mazak uraain tu us ki himmat pust ho jaate hai.. and I don't want that to happen to me.. that's all.

    I am sorry for misbehaving you last night.. but chal ab narazgi khatamm. mein bhi guilty feel kar raha tha after I went offline.. I m extremely sorry for it..
    [/offtopic]

    Regards,
    Omair Haroon
    36Host.com - $36/year web hosting [affiliates earn 30%]
    * Affordable Small Business Web Hosting since 2003! *
    "500mb space, 10gb bandwith, 50 pop/ftp accounts, php,
    mysql, pre-installed php scripts, 24/7 support & more...."



  11. #11
    SitePoint Addict
    Join Date
    Feb 2000
    Location
    Vilnius, Lithuania
    Posts
    203
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by qslack
    I've never seen that sort of syntax. I just tried it on MySQL and it gave an error, so even if it works on your system, it's not widespread. Try this:

    insert into webdesign set title='sdas', author='sd', email='as', desc='dasda', article='ads', about='sd', pid='2';

    I don't know your table structure but you could also use: insert into webdesign values(...);.
    Quinn: the "classic" insert statement is "insert into <table name> [(<field1>[,<field2>...])] values (value1[,value2..])" . This should work with any database claiming support for the basic sql standard. The one you've written above with "set field1=value1" looks more like update statement.
    SPAW Editor v.2 - web based wysiwyg editor for PHP and ASP.NET.
    Opera and Safari support, tabbed interface, floating toolbar...

  12. #12
    SitePoint Guru
    Join Date
    Dec 2000
    Location
    Karachi, Pakistan
    Posts
    913
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    guess we are not fighting over the insert statement..

    you are here to solve the problem.. j/k


    Please help me..

    Regards,
    Disheartened Omair
    36Host.com - $36/year web hosting [affiliates earn 30%]
    * Affordable Small Business Web Hosting since 2003! *
    "500mb space, 10gb bandwith, 50 pop/ftp accounts, php,
    mysql, pre-installed php scripts, 24/7 support & more...."



  13. #13
    Just Blow It bronze trophy
    DaveMaxwell's Avatar
    Join Date
    Nov 1999
    Location
    Mechanicsburg, PA
    Posts
    7,290
    Mentioned
    122 Post(s)
    Tagged
    1 Thread(s)
    Isn't desc a reserved word in SQL?
    Dave Maxwell - Manage Your Site Team Leader
    My favorite YouTube Video! | Star Wars, Dr Suess Style
    Learn how to be ready for The Forums' Move to Discourse

  14. #14
    SitePoint Addict
    Join Date
    Feb 2000
    Location
    Vilnius, Lithuania
    Posts
    203
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do you have any autonumber fields (pid for example) in your table? If so you can't specify a value for autonumber field in an insert statement.
    SPAW Editor v.2 - web based wysiwyg editor for PHP and ASP.NET.
    Opera and Safari support, tabbed interface, floating toolbar...

  15. #15
    SitePoint Addict
    Join Date
    Feb 2000
    Location
    Vilnius, Lithuania
    Posts
    203
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by DaveMaxwell
    Isn't desc a reserved word in SQL?
    Heh.. I believe that's the answer to your problem. I once had the same problem and spent some time figuring it out but I haven't noticed it in your statement
    SPAW Editor v.2 - web based wysiwyg editor for PHP and ASP.NET.
    Opera and Safari support, tabbed interface, floating toolbar...


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •