Re: note 11223 added to str_replace

From: Date: Mon, 12 Feb 2001 07:30:20 +0000
Subject: Re: note 11223 added to str_replace
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-10939@lists.php.net to get a copy of this message
Hi again Dwight I re-read your original email again. What was the idea behind doing the single quote -> 2 single quotes replacement? To insert a single quote into MySQL, it has to be escaped w/ a backslash not w/ another quote. The function addslashes() would do that (and some more). If I remember well it is Sybase the one that needs to use a single quote to escape another single quote. BTW, could not connect to the URL you mention in your last email. Good luck. --- Dwight Walker <dwight@wwwalker.com.au> wrote: > I use www.LinuxWebHost.com. According to the config: > > www.swap4free.com.au/phpoptions.php3 > > magic_quotes_runtime is Off > > It doesn't make sense that that happened. It just > happened out of the blue. > Before I had two ' marks and it worked. Then it > stuffed up so by trial and > error I worked out the system had put in a \ before > the first ' and then the > second ' stuffed up the INSERT. Who knows the > hosting company may have > changed something inside. > > I'll use the workaround for now. It is hard to get > hosting companies to do > anything you want mate!! > > ----- Original Message ----- > From: "Jesus M. Castagnetto" > <jmcastagnetto@yahoo.com> > To: <dwight@wwwalker.com.au>; > <php-notes@lists.php.net> > Sent: Sunday, February 11, 2001 5:27 PM > Subject: Re: [PHP-NOTES] note 11223 added to > str_replace > > > > Have you checked if you have magic_quotes active > in > > your config?. This seems like a side effect of > that > > option in your php.ini (or httpd.conf). > > > > Your note will be removed, as this is known effect > and > > it is mentioned in the "Configuration" section of > the > > manual. > > > > set_magic_quotes_runtime() may help you. > > > > If you do see this behavior even after turning off > > magic_quotes in your config, it may be good to > sumbit > > it to bugs.php.net > > > > > > --- dwight@wwwalker.com.au wrote: > > > It inserts a backslash for you - weird > sideeffect if > > > you are doing mysql inserts - stuffs up inserts > if > > > you use: > > > > > > $fieldname = "18' doughboy pool"; > > > > > > str_replace ("'", "''", $fieldname); /* two ' > marks > > > */ > > > > > > -> $fieldname = "18\'' doughboy pool"; > > > > > > which breaks INSERT in mysql > > > > > > Here is what works: > > > > > > $fieldname = "18' doughboy pool"; > > > > > > str_replace("'", "'", $fieldname); /* one ' mark > */ > > > > > > -> $fieldname = "18\' doughboy pool"; > > > > > > > > > > > > http://www.php.net/manual/en/function.str-replace.php > > > > > > > > > > > > -- > > > PHP Notes Mailing List (http://www.php.net/) > > > To unsubscribe, e-mail: > > > php-notes-unsubscribe@lists.php.net > > > For additional commands, e-mail: > > > php-notes-help@lists.php.net > > > To contact the list administrators, e-mail: > > php-list-admin@lists.php.net > > > > > > ===== > > --- Jesus M. Castagnetto <jmcastagnetto@php.net> > > > > __________________________________________________ > > Do You Yahoo!? > > Get personalized email addresses from Yahoo! Mail > - only $35 > > a year! http://personal.mail.yahoo.com/ > > ===== --- Jesus M. Castagnetto <jmcastagnetto@php.net> __________________________________________________ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail - only $35 a year! http://personal.mail.yahoo.com/

« previous php.notes (#10939) next »