dealing with apostrophes when inserting and reading from a postgreSQL database
Posted on 2006-07-12
I am using this code:
echo "<input type='text' name='passwordquestion' value='".htmlspecialchars(stripslashes(trim($row['passwordquestion'])))."' size='50'>";
when displaying a field from a database which may include an apostrophe within the text. If the text is "Mother's maiden name" then it is only showing the word Mother in the box displayed on screen, but if you view the source of the page, the value of the field is the full text.
When I am adding the value into the database, I am using this code around the data:
$mypwdQn = $_POST['passwordquestion'];
$mypwdQn = addslashes($mypwdQn);
The data is added fine into the database.
Can someone please help me to get the data to display correctly in the input box?