Hello,
I have in my drop-down menu company names that can have apostrophe's
imbedded i.e. Vic's Coffee Shop which shows fine in the menu. However, when
the user updates other fields on the form and presses the update buton it is
truncating the company name field and it only sees the data in front of the
' sign i.e. Vic. You'll notice that right after the foreach($_POST as
$field => $value) I am echoing the results of each field and the company
field is truncated after the ' sign. Magic Quotes is on if this has anything
to do with the problem.
Can someone please tell me why???
TIA
Vic
Here's the code to load the dropdown menu:
<?PHP
$table = "tblCompanies";
$Link = mysql_connect ($host, $user, $password);
$Query = "select concat(compID,'; ',compName)
as comp_name from $table";
$results = mysql_db_query($database, $Query, $Link);
?>
<tr><td align="right"><b>Delivery Company:</b></td>
<td><select name = "theCompany" >
<Option Value=" ">Select Delivery Company:</option>
<?PHP
for($u=0;$u<mysql_num_rows($results); $u++)
{
$company=mysql_result($results,$u,'comp_name');
echo "<option value='$company'";
if ($company == $searchCompany)
{
echo "selected";
}
echo ">$company\n";
?>
</option>
<?PHP
}
?>
</select>
when the form is updated and the page is reloaded thiscode is run :
case "Update":
foreach($_POST as $field => $value)
{
echo "value of $$field is $value ;";
if ($field == "theCompany")
{
$$field = strip_tags(trim($value));
$pos = strpos($$field, ";");
$len = strlen($$field);
$searchCompany = $$field;
$compID = substr($$field, 0, $pos); // returns the company id
}