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&N
titleunit_name=O'Fallon & Highway K&N
cleantitleunit_name=O\'Fallon & Highway K&N
This is what I get:
baroffice=O'Fallon
titleunit_name=O'Fallon & Highway K&N
cleantitleunit_name=O\'Fallon & Highway K&N
I don't know if it matters but the values are normally coming from and being sent back to ms sql.
<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=$cleantitleunit_name name= '$titleunit_name'>";
echo "$titleunit_name</option>";
?>
</select></div><br>
<br><Br>
<input type="submit" name="submit" value="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 "";
};
?>
Thanks for any help in advance.