View Full Version : Special characters in a database input form
07-09-2011, 01:11 AM
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 www.countyfairgrounds.net/entertainersforhire.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!!!
07-09-2011, 01:32 AM
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:
Joe said, "I'm going to do this!"
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:
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.
07-09-2011, 02:00 AM
??? 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.
07-09-2011, 07:24 AM
You can use htmlentities() (http://php.net/manual/en/function.htmlentities.php) to convert any special characters in your database to their html entity value for display in the browser and validation.
07-10-2011, 04:42 AM
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.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.