RE: [PHP] php mysql apostrophe issue

From: Date: Sun, 04 May 2003 16:03:44 +0000
Subject: RE: [PHP] php mysql apostrophe issue
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-146363@lists.php.net to get a copy of this message
Okay, I don't need to replace it, but now when I am getting the info from the mysql database that has an apostrophe in it, it just cut's off everything from the apostrophe on. For example, I am reading in a field that contains "I like my dad's haircut." But then I go to output it, and it reads, "I like my dad" Any ideas? Matt -----Original Message----- From: John W. Holmes [mailto:holmes072000@charter.net] Sent: Sunday, May 04, 2003 11:35 AM To: 'Matt Palermo'; php-general@lists.php.net Subject: RE: [PHP] php mysql apostrophe issue > I know that in order to insert an apostrophe into a mysql database, > instead of putting one apostrophe, you need to put double apostrophes. > So to do this, I am using the command: > > $NewTitleBox=eregi_replace("'", "''", $TitleBox); > > but instead of replacing the apostrophe with a double apostrophe, it > replaces it with this \'' You probably have magic_quotes_gpc enabled, which is adding the backslash before the original single quote. Then your str_replace() is duplicating the single quote. For mysql, the single quote can be escaped with a backslash or another single quote. So, since magic_quotes appears to be on, you do not need to do anymore escaping of the text. ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#146363) next »