Jump to content

Accent is ok when displaying in phpMyAdmin, but not on the page


tivrfoa

Recommended Posts

Hi,

 

I'm using PHP and MySQL.

It's working fine at my PC (localhost), but it's not on my web hosting.

 

Cordão -> should be Cord?o

 

It's displaying Cord?o at phpMyAdmin. So I checked the collate and character set to see if it's different.

They were, so I changed:

alter DATABASE db_name CHARACTER SET latin1 COLLATE latin1_swedish_ci;

alter table table_name CHARACTER SET latin1 COLLATE latin1_swedish_ci;

 

But this didn't resolved the problem.  :'(

What else might be the problem?

I don't think it's <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> because it's all working fine at my notebook.

 

Regards,

Leandro.

Link to comment
Share on other sites

Hi,

 

So ... when I insert the data through the phpMyAdmin page, it displays correctly in phpMyAdmin but not on the page (where matters).

I created a web form to fill the table from there, and then the data displays incorrectly in phpMyAdmin, but correctly in the page!

 

Well. Problem solved I guess. One thing that I'll test is if the collate and character set matters (I changed from utf8 to latin1), or the problem was because I inserted directly using phpMyAdmin.

 

Regards,

Leandro.

Link to comment
Share on other sites

When working with databases, and especially non-english content, there are 4 places where you need to ensure the right charset:

  1. [*]The database table/row, as you noted above.

[*]The database connection, as noted by jazzman1.

[*]The scripting language features, as you will probably need to use MB-compatible functions for most content.

[*]The HTTP headers.

Note that only using the meta HTML headers will probably not help, as the HTTP headers override them (if set). That means that if the server is sending out a different HTTP content header, then your meta-equiv is happily ignored by the browser.

 

You'll also want to make sure you're using the same charset in all four places, as mixing charsets is akin to begging for troubles like the one you're experiencing. With no easy way to fix it once it's happened, besides manually fixing every single instance yourself.

Link to comment
Share on other sites

Before sending the query string to your database, add this:

mysql_query('SET NAMES utf8");

http://forums.mysql.com/read.php?103,22311,249326

 

Hi,

 

The problem occurs when the data is inserted using phpMyAdmin. This function is not necessary in my script.

And this function is not recommended to change the charset. -> http://php.net/manual/en/function.mysql-set-charset.php

 

Thank you.

Link to comment
Share on other sites

When you use phpMyAdmin you have to make sure that phpMyAdmin uses UTF-8 (normally a choice at the login screen), and send the SET NAMES 'utf8' query before you do anything else.

If you keep everything to UTF-8 you'll have the least amount of problems possible.

Link to comment
Share on other sites

When you use phpMyAdmin you have to make sure that phpMyAdmin uses UTF-8 (normally a choice at the login screen), and send the SET NAMES 'utf8' query before you do anything else.

If you keep everything to UTF-8 you'll have the least amount of problems possible.

Hi,

 

I changed everything to utf8_bin: MySQL connection collation, database, table and column.

http://dev.mysql.com/doc/refman/5.0/en/charset-connection.html

 

And then I run in phpMyAdmin:

set names 'utf8';

update clientes set nome = 'Jos? In?s';

 

And the problem remains. Only display correctly at phpMyAdmin.

I also tested header('Content-type: text/html; charset=utf-8'); but didn't work.

http://www.w3.org/International/O-HTTP-charset.en.php

 

For display these data correctly I would need to use utf8_encode everywhere (ouch!!!).

 

It's interesting the number of comments that the page about utf8_encode has:

http://php.net/manual/en/function.utf8-encode.php

 

I'll read more, but meanwhile I'll fill the tables using PHP script and not phpMyAdmin.

 

Regards,

Leandro.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.