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 5 of 5
  1. #1
    Regular Coder
    Join Date
    Jan 2011
    Posts
    302
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Special characters in a database input form

    We are Countyfairgrounds.net and have a few data basis input forms. One of our databases has 9,000 entries in it. However the one that we are really having the problem with is http://www.countyfairgrounds.net/ent...ersforhire.php Apparently I am not going to be able to stop them for inputting apostrophes and quotes and dashes - My page will not html5 validate. It is not feasible to go through every entry and change all the characters these people are putting in . For one thing there are several input fields. My php guy is telling me the ONLY way to fix this is to go through each an every listing and take em out... BUT that would well be an ongoing thing. Tis not feasible. Can you please tel us how to fix this issue? WE would be enternally grafeful!!!

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,028
    Thanks
    75
    Thanked 4,325 Times in 4,291 Posts
    Nothing to do with the database.

    What would you do if your boss told you that an HTML page *MUST* contain those characters?

    How would you get it to validate?

    Answer: You'd use HTML entitites in place of the problem characters.

    That is, you'd code something like this, perhaps:
    Code:
        Joe said, "I'm going to do this!"
    Right?

    Okay, so you just need to encode (use entities) in place of the literal characters these people who create the postings put in there.

    I'm not a PHP person, but a quick perusal of http://www.php.net pops up these:
    http://www.php.net/manual/en/function.htmlentities.php
    http://www.php.net/manual/en/functio...ecialchars.php

    Is that all you need, perhaps?

    (Why are dashes problematical??)

    By the by, your "php guy" should have been able to figure this out, I would think.

  • #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,028
    Thanks
    75
    Thanked 4,325 Times in 4,291 Posts
    ??? Why are you worried about little stuff like " and so on when you have over ONE HUNDRED ERRORS that are caused by your own coding???

    You don't even have <title> spelled correctly, for example.

    You use <option name="xx"> which has been obsolete for at least 10 years.

    Well... Clean up your base page HTML first, *then* worry about the HTML entity encoding. It's the least of your problems.

  • #4
    Banned
    Join Date
    Feb 2011
    Posts
    2,699
    Thanks
    13
    Thanked 395 Times in 395 Posts
    You can use htmlentities() to convert any special characters in your database to their html entity value for display in the browser and validation.

  • #5
    Regular Coder
    Join Date
    Jan 2011
    Posts
    302
    Thanks
    7
    Thanked 0 Times in 0 Posts
    Thanks, I just passed it on to my php guy, - he is self taught and has not been able to figure this one out. So I will see what he says and get back to you. MUCH thanks.


  •  

    Tags for this Thread

    Posting Permissions

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