Single quotes and addslashes in php forms (option value escaping on space?)

Linn_77

New Member
I cannot get my addslashes function and html option value to play nice together. My initial problem was the single quote in the option but by solving that I seem to have created another issue whereby $titleunit_name only comes through with the first word.This is what I want to come out:baroffice=O'Fallon & Highway K&Ntitleunit_name=O'Fallon & Highway K&Ncleantitleunit_name=O\'Fallon & Highway K&NThis is what I get:baroffice=O'Fallontitleunit_name=O'Fallon & Highway K&Ncleantitleunit_name=O\'Fallon & Highway K&NI don't know if it matters but the values are normally coming from and being sent back to ms sql.\[code\]<form method="post" action="formtest.php?" id="searchform" target="" autocomplete="off"><div id="office"><font style="font-size:12px; font-weight:bold;" color="#002EB8" face="Verdana">Closing Office:</font><select name="baroffice" style="width:90px"><?php$titleunit_name= "O'Fallon & Highway K&N";$cleantitleunit_name=addslashes("$titleunit_name");echo "<option value=http://stackoverflow.com/questions/3918262/$cleantitleunit_name name='$titleunit_name'>"; echo "$titleunit_name</option>";?></select></div><br><br><Br><input type="submit" name="submit" value="http://stackoverflow.com/questions/3918262/submit" style="position:relative;z-index:3"><br><Br></form><?php$baroffice = str_replace("\'","'",($_POST['baroffice']));if (isset($_POST['submit'])){echo "baroffice=$baroffice<br>";echo "titleunit_name=$titleunit_name<br>";echo "cleantitleunit_name=$cleantitleunit_name<br>";}else{echo "";};?>\[/code\]Thanks for any help in advance.
 
Back
Top