0

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!

Davina
  • 21
  • 7

1 Answers1

0

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