Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases 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 July 1st, 2004, 11:31 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Adam H-W
Default syntax errors

Hi there

I've got a couple of syntax errors that I was hoping someone could help me with:

1) I'm using ASP with MS SQL Server 2000 and I've got some varchar entries with a ' in them - i.e L'equipe. When the ASP spits them out I get an error - can I use the replace method to stop this? if so, how would it be written for the '?

2) I get a syntax error with this code.

response.Write("<a href=""submitworld.asp?Country='" & request.Form("Country") & "'&Beach='" & request.Form("Beach") & "' BeachID= '" & request.Form("BeachID"))

can anyone see how I can rectify either/both of these?

Many thanks

Adam


 
Old July 1st, 2004, 01:59 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 303
Thanks: 0
Thanked 0 Times in 0 Posts
Default

(1)
It depends on how you build your Response.Write statement.
Yes, Replace apostrophe with chr(39)

<script language="VBScript" type="text/VBScript">
Function Fix_String(varString)
    if isnull(varString) then
        Fix_String = ""
    else
        Fix_String = trim(varString)
        Fix_String = Replace(Fix_String,"'",chr(39))
    end if
End function
</script>
(2)
Response.Write("<a href='submitworld.asp?country="& Request.form("Country") & "Beach="&Request.Form("Beach") & "BeachID=" & Request.form("beachID") &"'></a>")

Let me know
 
Old July 1st, 2004, 09:37 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi shahchi1,

You are missing & in the querystring.

Adam, you can use this modified one.

Code:
Response.Write "<a href='submitworld.asp?country=" & Request.form("Country") & "&Beach=" & Request.Form("Beach") & "&BeachID=" & Request.form("beachID") &"'></a>"
Cheers!

_________________________
- Vijay G
Strive for Perfection
 
Old July 1st, 2004, 09:49 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Adam,

I am not sure if shahchi1's Replace code works. So try this.

Code:
ELSE
    Fix_String = trim(varString) ''' Do not use this. Remove this line
    'Once something is assigned to the FUNCTION name, the value that is assigned is returned to the calling code. 
    'You cannot do that twice. And the next line would never be executed as the control switches out of FIX_STRING function after this. 
    'So the above line should return control to calling code, and you would not get the replace of "'" with chr(39) effected.
    Fix_String = Replace(trim(varString),"'",chr(39))
END IF
Hope that helps.
Cheers!

_________________________
- Vijay G
Strive for Perfection
 
Old July 2nd, 2004, 07:44 AM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 303
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Vijay,
My bad, but thank you for corrections






Similar Threads
Thread Thread Starter Forum Replies Last Post
Errors Nate L BOOK: Professional CodeIgniter ISBN: 978-0-470-28245-8 2 October 20th, 2008 10:01 PM
Can't get errors to display with <html:errors> michaeldill JSP Basics 0 August 2nd, 2004 01:47 PM
Scripting Syntax Errors, please help Matt6sic6 Javascript 5 June 1st, 2004 12:22 AM
errors and fixing errors Droopy XML 0 August 26th, 2003 12:47 AM
Errors Errors DB Errors Ljhopkins VS.NET 2002/2003 0 July 15th, 2003 12:42 PM





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