I don't have a problem SENDING an apostrophe-containing string to a MySQL database using the form attached. That's fine...I looked at the database and it contains the name of my dummy member as:
and doing an 'echo' shows the string sent as:
the problem comes when I try and DISPLAY this string on a form.
I have a page which contains a form, but at the top of the page is a little bit of PHP which displays the person's name:
$conn = dbconnect('member');
$showrow = "select * from clubs where username='$_SESSION[sessuser]'";
$result = mysql_query($showrow) or die(mysql_error());
while ($row = mysql_fetch_assoc($result))
$theun = $row['username'];
$thepw = $row['password'];
$thefn = ucwords($row['fname']);
$thephone = $row['landline'];
$themobile = $row['mobile'];
$themail = $row['email'];
$theclub = ucwords($row['club']);
and then on the page itself, this (which works as in the attached screenshot):
<h2>Member Details for <?php echo $thefn ?></h2>
However, in the form, which contains values retrieved from a MySQL query, everything is OK apart from that field which contains an apostrophe.
This is the relevant line:
<tr><td class="boldright">Name </td> <!-- name box -->
<td><?php echo "<input type='text' name='fname' value='$thefn' size='30' maxlength='30'>"; ?></td></tr>
But in this case the variable $thefn is only getting the result of the query up to the apostrophe after the O of O'Dwyer. How can it show it as correct in one place but not in the other?
PS - I have blanked out some values for security reasons, but they are retrieved for this member from the DB.