Forum Moderators: open
Strings are always displayed correctly on the webpage, but are not saved right on the database. For example, the spanish word "árbol" becomes "árbol" in the database. Yet it's always displayed right on the webpages.
The question is how do I save these strings with accents properly on the tables, and if PHP should make the conversion, how to do it.
Thanks in advance.
First I posted data from a form in a UTF-8 PHP/XHTML page and then stored it on a MySQL database using adodb.
Example of posted text:
árbol
Then, if I see the MySQL DB using phpMyAdmin, the text is shown as:
árbol
BUT, if I see the text from a UTF-8 PHP/XHTML file (UTF-8 encoded and correct UTF-8 meta tag) it is shown correctly (árbol).
¿Is the data been saved correctly?
¿Is it phpMyAdmin problem?... ¿Or am I doing something wrong?
Thx.
Using ADOdb:
$db_charset = $conn->Execute( "SHOW VARIABLES LIKE 'character_set_database'" );
$conn->Execute( "SET NAMES '" . $db_charset->fields['Value'] . "'" );
$db_charset->Close();
You could also use something simpler like:
@mysql_query("SET NAMES 'utf-8'");
[edited by: rogerd at 11:11 pm (utc) on Mar. 28, 2007]
[edit reason] No URLs, please... [/edit]