Forum Moderators: coopster

Message Too Old, No Replies

Help! With Slashes And Escaped Characters!

         

Shaman13

6:30 pm on Feb 17, 2005 (gmt 0)

10+ Year Member



I have what is probably an extremely stupid question. I haven't had any luck finding a solution so here I am back at my favorite forum pleading yes pleading for some help. My problem is with escaped characters. Specifically, apostrophes. I am using Php 4.3 and MySQL. I am using a form in which the user enters a name. After entering the name and submitting the form. the name is passed to a second form as a Session variable. My problem? When the name contains an apostrophe such as O'Brien A / gets inserted imediately before the apostrophe i.e. O/'Brien. This screws up all my subsequent forms that use this session variable. How can I get rid of the (^*2&%$ slash. Many thanks

This is the field that captures the name

input name="CLNAME" type="text" value="<?if (isset($CLNAME)) print $CLNAME;?>"

This is where I assign it to a session variable

$_SESSION['CLNAME'] = $CLNAME;

And this is where it appears on the second form

<input type="text" name="CLNAME" value="<? echo $_SESSION['CLNAME'];?>"

I know this must be doable with stripslashes or addslashes I just don't know how and where to implement that. Any and all suggestions are really appreciated! Have a Great Day!

xeonaphobe

9:07 pm on Feb 17, 2005 (gmt 0)

10+ Year Member



$_SESSION['CLNAME'] = stripslashes($CLNAME);

I'm pretty sure that would do it...

coopster

3:00 am on Feb 18, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Sounds like you are getting your first taste of PHP's magic quotes [webmasterworld.com] and how they work. Spend a few moments to browse that link and the associated PHP manual pages -- well worth your time ;)