I have a problem with string from my database mysql. I have a form with some input text and text area. I have a list of product with the button "Update". If I click this button the new page is so done:
<form action="modify.php">
<input type="text" name="name" value="<?php echo $name_from_db; ?>">
<br>
<input type="text" name="desc" value="<?php echo $desc_from_db; ?>">
<br/>
...
</form>
The problem are the lecters like "è", "à", ecc. In database arrive directely with that value and not with "è"
. But now in input form their value isn't correct.
I try to do this:
$desc_from_db= str_replace("è", "è", $desc_from_db);
Probably the charset (latin1_swedish_ci
) it's different.
What do I have to do?
EDIT I tried to do a solution and it seems work correctely. It isn't the best solution. Can you judge it? Could have some bug? The lecters dangerous are only 6: "à", "è", "ì", "ò", "ù", "é". So with the function: ord ($lecter) I notest that "è" have the code 232. So I could do (checking all the lecter of the word):
if(ord($lecter) == 232)
$word = substring($word, 0, $index)."è".substring($word, $index+1, strlen($word);