I am sure this is a very basic problem that I have overlooked for years but it hasn't ever been a problem.
I have a very simple php script with an HTML form which edits company information (stored in a MySQL database). The problem is where a company name includes an apostrophe like "Bob's Store"
The string is saved to the database using add slashes:
$company_name = addslashes(strip_tags($_POST['company_name']));
On the edit page, the string is retrieved using stripslashes:
$company_name = stripslashes($row_data['company_name']);
and echoed to the screen as part of the page title. The string looks fine.
The string is then included in the edit form as such:
<input type='text' name='company_name' size=55 maxlength=55 value='$company_name'>
The problem is that the text which appears in the input field is truncated after the apostrophe: "Bob".
If I remove the apostrophes around $company_name:
<input type='text' name='company_name' size=55 maxlength=55 value=$company_name>
the text is truncated after the space: "Bob's"
This script/form has been used for almost 20 years, there are more than 25K companies in the table and more than a thousand have apostrophes in their names and I've never had this problem.
What am I missing?