Re: addslashes()

From: Date: Fri, 08 Feb 2002 15:42:12 +0000
Subject: Re: addslashes()
References: 1 2 3 4  Groups: php.db 
Request: Send a blank email to php-db+get-16690@lists.php.net to get a copy of this message
It shouldn't. It will affect any " or ' coming out. For example, for going in to db: $mystring = "Hi there Mr O'Neil."; $mystring = addslashes($mystring); echo $mystring; would result in "Hi there Mr O\'Neil." When coming out of db make sure you use the stripslashes function to return the original value that was created upon entry $mystring = stripslashes($mystring); would result back to "Hi there Mr O'Neil." HTH Joe :) "Todd Williamsen" <todd@williamsen.net> wrote in message news:20020208151625.22917.qmail@pb1.pair.com... > So if I: > Going in > $Notes = addslashes($Notes); > > Going Out: > $Notes = stripslashes($Notes); > > wouldn't that kill the html? or no? > "Joe Van Meer" <vanmeer@accesscable.net> wrote in message > news:20020208004317.841.qmail@pb1.pair.com... > > Hi. addslashes() going in to db, stripslashes() coming out :) > > HTH Joe :) > > > > > > Todd Williamsen <todd@williamsen.net> wrote in message > > news:002601c1b033$382a4700$f6b2d83f@goofy1... > > > Paul, > > > > > > It is being inserted into a database > > > > > > -----Original Message----- > > > From: Paul DuBois [mailto:paul@snake.net] > > > Sent: Thursday, February 07, 2002 5:41 PM > > > To: Todd Williamsen; php-db@lists.php.net > > > Subject: Re: [PHP-DB] addslashes() > > > > > > > > > At 16:54 -0600 2/7/02, Todd Williamsen wrote: > > > >Ok.. > > > > > > > >i tried it out... and it almost works like I want it... weird though > > > > > > > >1. when I put in <p><font color="blue">this is > > > >BLUE</p></font> > > > > > > > >it prints it in like a bright green. but if i use the RGB # then its > > > fine. > > > >weird.... > > > > > > > >2. if there is an apostrophe in the notes, then it will add slashes it > > > to > > > >that as well > > > > > > > >so if I type blah blah blah I am going over to my friend's website > > > later on > > > >and here is the address... > > > > > > > ><a href="lñ0jbu > > > >À³Ø$¢ˆC®http://friends.com>Friends</a> > > > > > > > >it will look like > > > > > > > >friend\\\'s > > > > > > > >Friends(link) > > > > > > addslashes() is for escaping values that you're going to insert into a > > > database. > > > > > > If you're generating HTML, use htmlspecialchars() instead. > > > > > > > > > > > >

« previous php.db (#16690) next »