littlepeg Posted May 23, 2007 Share Posted May 23, 2007 Hi everybody. I am a new learner for php & MySQL and have one easy question would like to ask for advice. How can I store content in the database when they have some special symbols. For example, one thing I need to store is time: between 12:00am-15:00pm. when I output it using php, it becomes like 12:00am?15:00pm. In addition, the other one is "company's", and this output became company?s. Any help would be grately and appreciated. Quote Link to comment Share on other sites More sharing options...
emehrkay Posted May 23, 2007 Share Posted May 23, 2007 are those quoes and dashes from a MS product? if they were regular html characters, they should store fine, but if the were of the "smart" variety, the browser would have trouble displaying them and mysql wouldnt understand them either. one you figure that out, use htmlentities and mysql_real_escape_string before storing data Quote Link to comment Share on other sites More sharing options...
taith Posted May 23, 2007 Share Posted May 23, 2007 if you want... just htmlentities($string,ENT_QUOTES); then all them issues go byebye... Quote Link to comment Share on other sites More sharing options...
littlepeg Posted May 23, 2007 Author Share Posted May 23, 2007 Hi, thank you for your reply. My situation is that I stored some web content within a database, and then use php code to display them on the website. So would you please tell me that how do I use this htmlentities($string, ENT_QUOTES)? Quote Link to comment Share on other sites More sharing options...
taith Posted May 23, 2007 Share Posted May 23, 2007 htmlentities just changes troublesome characters, into their html counterparts... ' -->' " -->" @ -->& and the likes :-) just put that into where you enter stuff into the database, then, everyone's happy... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.