Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10

Thread: ASP help...

  1. #1
    New to the CF scene
    Join Date
    Sep 2005
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ASP help...

    I have created a simple shopping cart, but I have run into a problem that is giving me fits. It is for a automotive site. Just a little background first. The database has a table that hold all the part/items. It has fields for part number, name, description, catagory, and price. One the first screen I have created a link column where the user can click on a catagory and it will search the items table for all items that have that catagory listed. Now my problem. When the catagory has a symbol in it, such as "Wheel & Tires" it only searches for Wheel. It works just fine for catagories such as "Pistons" or any catagory with out the symbols. I am passing it info through the querystring.
    Currently it is worded as
    <a href="page.asp?cat=<% rs("cat") %>">Catagory</a>.

    If I us this...
    <a href="page.asp?cat= ' <% rs("cat") %> ' ">Catagory</a>

    It works fine still for non-symbols but gives a error for "Wheel & Tires".

    Any suggestion on how to many symbols such as &?

    Thanks in advance.
    WPiersol

  • #2
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,174
    Thanks
    19
    Thanked 66 Times in 65 Posts
    your issue is that you're passing values through the querystring... & splits values in the querystring... Is there any reason why you have to send it through the querystring like that?
    You could replace it with another symbol that you know you wont be using then undo the replace at the other end

  • #3
    Senior Coder TheShaner's Avatar
    Join Date
    Sep 2005
    Location
    Orlando, FL
    Posts
    1,126
    Thanks
    2
    Thanked 40 Times in 40 Posts
    Like Nancy pointed out, your query string looks like:

    page.asp?cat=Wheel & Tire

    which means that when grabbing the value for cat, it will only pick out Wheel and the extra white space after since values are delineated by the = and & signs. Because look at this query string for example:

    page.asp?cat=Car&make=Mazda

    cat's value is Car and make's value is Mazda. The & sign divides the two in the query string. So your & sign in Wheel & Tire is confusing the program. So you either use another symbol and then replace that symbol with the & sign later on as Nancy suggested or you could just change the & sign to the word "and" instead.

    -Shane

  • #4
    New to the CF scene
    Join Date
    Sep 2005
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the input. I thought the was the case, and that is why I wrapped the script in quotes in my second attempt ( <a href="page.asp?cat=' <% .... %>' " >). I guess I'll use the replace function. I have not used that function before, I guess I'll search for it and read up.

    Thanks again.

    WPiersol

  • #5
    New to the CF scene
    Join Date
    Sep 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I would use JavaScript to encode your values for your query string with the function:

    escape(s)

    Where s is the string you want to url encode. You can also use:

    unescape(s)

    to unencode your encoded data.

  • #6
    Regular Coder
    Join Date
    Sep 2004
    Posts
    152
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Change this: <a href="page.asp?cat=<% rs("cat") %>">Catagory</a>. To this: <a href="page.asp?cat=<% Server.HTMLEncode(rs("cat")) %>">Catagory</a>. That will fix your problem.

  • #7
    New to the CF scene
    Join Date
    Sep 2005
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If the only problem is the ampersand in the querystring just use Server.URLEncode

    <A href='page.asp?cat=<%=Server.URLEncode("my goofy & weird text")%>'>goofy query</a>

  • #8
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,174
    Thanks
    19
    Thanked 66 Times in 65 Posts
    Quote Originally Posted by neocool00
    Change this: <a href="page.asp?cat=<% rs("cat") %>">Catagory</a>. To this: <a href="page.asp?cat=<% Server.HTMLEncode(rs("cat")) %>">Catagory</a>. That will fix your problem.
    htmlencode does nothing to ampersands... I tried that before posting
    urlencode might work though, forogot aboutt hat one

  • #9
    New to the CF scene
    Join Date
    Sep 2005
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If I used <A href='page.asp?cat=<%=Server.URLEncode("my goofy & weird text")%>'>goofy query</a> Would I have to "UN-ENCODE" it on the recieving page?

    WPiersol

  • #10
    New to the CF scene
    Join Date
    Sep 2005
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile

    You guys rock! Thanks for your help!

    WPiersol


  •  

    Posting Permissions

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