SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Guru
    Join Date
    Feb 2006
    Location
    Chepstow, South Wales
    Posts
    915
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Validation error cause by spaces in value of url string

    I have added an option on my clients website to allow visitors to enquire about their stock, its just a simple click and then they get a pop up form, they love it as they are getting more business, but its creating 1 validation error which is stopping me getting the green light, and its very annoying.

    Here is the link to the validator and the error -

    http://validator.w3.org/check?uri=ht...Inline&group=0

    When the user clicks the link on the site its grabbing the name of the clock and the ref number and passing it to the pop up via the url, and basically the spaces between the names is whats causing the errors.

    you can see it for yourself by going here -

    http://www.pendulumofmayfair.co.uk/p...automaton-rare

    and click 'here' in the click here to make an enquiry above the clock.

    By the way i didnt build this site, its quite old and I'm helping out with SEO, and the code below is where I need some help.

    Code:
    OpenDB
    sSQL = "SELECT * FROM products WHERE PID = " & pid & " AND (Status = 'SHOW' OR Status = 'SOLD')"
    OpenRS(sSQL)
    If Not rs.BOF And Not rs.EOF Then
    arr = rs.GetRows
    For i = 0 To UBound(arr,2)
    set fs=Server.CreateObject("Scripting.FileSystemObject")
    wr "<div class='Clock' style='position:relative; width:100%; height:22px; line-height:25px; text-align:center;'>I am interested in this item - click <a href='../stock_Enquiry.asp?ID=" & pid & "&amp;Name=" & arr(1,i) & "' style='font-size:12px; text-decoration:underline;' onClick='showPopup(this.href); return(false);'>here</a> to make an enquiry" & vbcrlf
    wr "</div>" & vbcrlf
    And this bit in particular.

    Code:
    Name=" & arr(1,i) & "
    As it drawing the info from the array, what I need to try and do is take value within that region of the array, change the spaces for somehting like %20 and then put it back together, which will solve the spaces between the value problem, and hopefully allow the validator to give me the green light.

    Thanks

  2. #2
    SitePoint Guru
    Join Date
    Feb 2006
    Location
    Chepstow, South Wales
    Posts
    915
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thought something like this would work, but causes the page to crash:

    Code:
    Replace(arr(1,i))," ","%20")
    Microsoft VBScript compilation

    error '800a0401'
    Expected end of statement
    /includes/functions.asp, line 463Replace(arr(1,i))," ","%20")

  3. #3
    SitePoint Guru
    Join Date
    Feb 2006
    Location
    Chepstow, South Wales
    Posts
    915
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, solved the error and will now see if the validator works.

    Code:
    arr(1,i) = Replace(arr(1,i)," ","%20")
    Yep Bingo, it worked...

    Code:
    arr(1,i) = Replace(arr(1,i)," ","&nbsp;")

  4. #4
    SitePoint Wizard bronze trophy
    Join Date
    Oct 2001
    Location
    Vancouver BC Canada
    Posts
    2,037
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    Glad that worked out. Whenever I run into areas where I need to work with querystrings I start with urlencode() and urldecode(), then I build my solution around it filling in any gaps if need be.
    Andrew Wasson | www.lunadesign.org
    Principal / Internet Development


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
  •