Hi!
When I entered strings with ñ and Ñ, they will be saved in the database as is with no problem.
However, when retrieved from the database, ñ becomes ñ and Ñ becomes Ñ
Is there any way that when I fetched the results from the database, the special characters will remain intact?
Mysql problem with ñ and Ñ - SOLVED
Moderator: General Moderators
Mysql problem with ñ and Ñ - SOLVED
Last edited by deeessay on Sat Sep 13, 2008 2:47 am, edited 1 time in total.
Re: Mysql problem with ñ and Ñ
I had this same problem i solved it when saving things to db using htmlentities...
Example:
hope this helps!
Example:
Code: Select all
$ctitle = htmlentities($title);
$msg = htmlentities($message);
$query = "INSERT INTO news_posts (title, author, post, DATE) VALUES ('$ctitle', '$nam', '$msg', NOW())";Re: Mysql problem with ñ and Ñ
It's not an issue with MySQL, it's an issue with your pages encoding. Remember to set it with the relevant HTTP header or meta content-type.
This is also not the correct forum to ask coding or database questions. There are two forums for both.
This is also not the correct forum to ask coding or database questions. There are two forums for both.
Re: Mysql problem with ñ and Ñ
Thank you all for replying!
I used
mysql_query("SET NAMES 'utf8'");
mysql_query("SET CHARACTER SET 'utf8'");
and the ñ and Ñ are now saved in the database as is. My problem now is when fetched from the database, the characters are different. I tried using
htmlentities
htmlspecialchars
htmlspecialchars_decode
and
html_entity_decode
but to no avail...
I used
mysql_query("SET NAMES 'utf8'");
mysql_query("SET CHARACTER SET 'utf8'");
and the ñ and Ñ are now saved in the database as is. My problem now is when fetched from the database, the characters are different. I tried using
htmlentities
htmlspecialchars
htmlspecialchars_decode
and
html_entity_decode
but to no avail...
Mysql problem with ñ and Ñ -- SOLVED
Hi again, I finally got it working. Thanks to Jenk and BETA for helping. For the benefit of those who will encounter the same problem in the future, here's what I did:
query these first before inserting or updating the database:
mysql_query("SET NAMES 'utf8'");
mysql_query("SET CHARACTER SET 'utf8'");
then, on the page that will display the special characters, add this in between the <head></head> tags:
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
query these first before inserting or updating the database:
mysql_query("SET NAMES 'utf8'");
mysql_query("SET CHARACTER SET 'utf8'");
then, on the page that will display the special characters, add this in between the <head></head> tags:
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
Re: Mysql problem with ñ and Ñ - SOLVED
Np!
Well ur solution doesn't work for me cause i can't print characters like they i need to parse them into their correct html entity
example using ur solution prints out:
e tan dif�cil como pensaba... Me ha costado casi un d�a
:S
thx anyway!
Well ur solution doesn't work for me cause i can't print characters like they i need to parse them into their correct html entity
example using ur solution prints out:
e tan dif�cil como pensaba... Me ha costado casi un d�a
:S
thx anyway!