Jump to content


Soo about PHP, text fields, and single quotes.


  • Please log in to reply
1 reply to this topic

#1 _*Calamari_*

_*Calamari_*
  • Guests

Posted 28 February 2004 - 03:04 AM

Hey all,

I'm trying to do a simple form input into a mysql database. Seems simple enough, like the one I'm typing into right now in fact. Problem is, either mysql or php is truncating the string when I get to any single quotes. I've tried addslashes and stripslashes, and while they display properly before they hit the DB, once they get inserted they get chopped off. Oh, I've also tried mysql_escape_string. Any help is appreciated.

P.S. Thanks for the help on my last question, the jscript was the answer :unsure:

#2 _*Shao_*

_*Shao_*
  • Guests

Posted 28 February 2004 - 10:24 PM

Just replace the single quote with the html encode equivalent (like   for a space etc...) by calling htmlencode function I think. Look into the php website for the proper function for encoding. I think the proper html entity is ' Try it and test it.

Or you could use ereg_replace(string pattern, string replacement, string string), or preg_replace (suppose to be faster in perl - as documented and tested).

Good Luck!

PS: Bookmark the php.net website! If you're going to code in php, that's the best place for any solution.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users