Davina Davina - 10 months ago 30
PHP Question

when retrieving data a part of it doesn't appear because of the sign " ' "

I'm trying to retrieve data from mysql database using php and mysqli
but when the result show up there is some fields that are not complete for example:
the field in the database is: domaine de l'agricultule
but when it show up is like: domaine de l

echo "<input type='text' name='domaine' size='80' dir='ltr' value='{$row['domaine']}'/>";

help please where i the problem!


the issue is the html created with that value becomes invalid due to the apostrophe, so you need to encode it like so:

 echo "<input type='text' name='domaine' size='80' dir='ltr' value='".htmlspecialchars($row['domaine'], ENT_QUOTES)."' />";

you could change value to use " (double quotes), but that could still cause problems depending on the potential values of domaine

Ref: http://php.net/manual/en/function.htmlspecialchars.php