+ Post New Thread
Results 1 to 13 of 13
Web Development Thread, ASP, Access and £ Signs in Coding and Web Development; ...
  1. #1

    Join Date
    Sep 2007
    Posts
    181
    Thank Post
    4
    Thanked 2 Times in 2 Posts
    Rep Power
    15

    ASP, Access and £ Signs

    I am having a problem when using an ASP script to enter data into an Access database. All is fine until I enter text containing a £ sign. The £ sign seems to get replaced with an accented A£, or goes missing altogether. All other symbols such as ! " $ %, etc, work fine.

    Has anyone seen this problem before, and if so what could be causing it?

  2. #2

    webman's Avatar
    Join Date
    Nov 2005
    Location
    North East England
    Posts
    8,417
    Thank Post
    644
    Thanked 965 Times in 665 Posts
    Blog Entries
    2
    Rep Power
    328
    Sounds like it could be to do with the character set/encoding. If you open up the DB in Access, is it the correct symbol or the accented character?

    Do you have this within your <head> tag?

    Code:
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    Last edited by webman; 29th March 2010 at 11:11 AM.

  3. #3

    Join Date
    Sep 2007
    Posts
    181
    Thank Post
    4
    Thanked 2 Times in 2 Posts
    Rep Power
    15
    If I open the database, it also contains the extra characters.
    I haven't god a line in the header like your example though. Should there be?

  4. #4

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,158
    Thank Post
    116
    Thanked 529 Times in 452 Posts
    Blog Entries
    2
    Rep Power
    124
    Can you store the data as &pound; rather than £ (see HTML ISO-8859-1 Reference)

    What is entering the data? Are you collecting it from a web form or just entry directly into Access?

  5. #5

    webman's Avatar
    Join Date
    Nov 2005
    Location
    North East England
    Posts
    8,417
    Thank Post
    644
    Thanked 965 Times in 665 Posts
    Blog Entries
    2
    Rep Power
    328
    I think that would help displaying the £ character itself if it was stored as that, it can't hurt trying.

    But ideally, it should be using the &pound; HTML entity reference. If you convert incoming £ symbols from user input on a form to &pound; before you insert into the DB, there should be no issues displaying it back on the page.

  6. #6

    Join Date
    Sep 2007
    Posts
    181
    Thank Post
    4
    Thanked 2 Times in 2 Posts
    Rep Power
    15
    Yes, entering &pound works correctly and displays as £.
    Data is being entered via a form, so is there a way of the form converting that data before it goes into the database?

  7. #7

    webman's Avatar
    Join Date
    Nov 2005
    Location
    North East England
    Posts
    8,417
    Thank Post
    644
    Thanked 965 Times in 665 Posts
    Blog Entries
    2
    Rep Power
    328
    Bit rusty with classic ASP, but there should be something like str_replace() should do the job.

    EDIT: What the next reply says

  8. #8

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,158
    Thank Post
    116
    Thanked 529 Times in 452 Posts
    Blog Entries
    2
    Rep Power
    124
    I'm guessing you've got something like:
    Code:
    sText=request.form("data_entry_box")
    and you then go on to store that in the db. Replace this with:
    Code:
    sText=request.form("data_entry_box")
    sText=replace(sText,"£","&pound;")

  9. #9

    Join Date
    Sep 2007
    Posts
    181
    Thank Post
    4
    Thanked 2 Times in 2 Posts
    Rep Power
    15
    I'm using almost exactly that, only text instead of sText. Does that matter?
    Have tried adding the replace line, but it's still not writing £ to the database.

  10. #10

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,158
    Thank Post
    116
    Thanked 529 Times in 452 Posts
    Blog Entries
    2
    Rep Power
    124
    variable name doesn't matter.
    It shouldn't be writing "£" to the db but should be encoding it.
    Can you try:
    Code:
    Text=request.form("data_entry_box")
    if instr(text,"£")>0 then response.write "got a pound sign"
    Text=replace(sText,"£","&pound;")
    just as some debugging - want to see what you're actually getting from the text entry box.

  11. #11

    Join Date
    Sep 2007
    Posts
    181
    Thank Post
    4
    Thanked 2 Times in 2 Posts
    Rep Power
    15
    That's strange... got a blank page when I tried that.

  12. #12

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,158
    Thank Post
    116
    Thanked 529 Times in 452 Posts
    Blog Entries
    2
    Rep Power
    124
    OK; looks like it's not even capturing the £ sign.

    What happens if you just put a:

    Code:
    response.write request.form
    that way you can see everything that's being passed.

  13. #13

    Join Date
    Sep 2007
    Posts
    181
    Thank Post
    4
    Thanked 2 Times in 2 Posts
    Rep Power
    15
    I've just added the character set line to the head of the file which writes to the database line. It seems to be working now.
    Thanks for everyone's help on this one. Much aprpeciated.



SHARE:
+ Post New Thread

Similar Threads

  1. [Website] 50 Best Protest Signs of 2009
    By mattx in forum Jokes/Interweb Things
    Replies: 3
    Last Post: 9th January 2010, 09:20 PM
  2. Open password protected access 2007 database with ASP
    By ryan_powell in forum Web Development
    Replies: 0
    Last Post: 31st January 2008, 03:52 PM
  3. Free ASP CMS type jobbie for our intranet MS Access
    By Scotmk in forum Web Development
    Replies: 4
    Last Post: 15th June 2007, 08:43 AM
  4. Preston Signs
    By Preston in forum General Chat
    Replies: 10
    Last Post: 26th April 2006, 04:51 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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