Bluehost MySQL Country Specific Characters Encoding - php

I have just moved my site from godaddy to bluehost. Everything works just great with my new host provider, except come encoding issues.
My site is build on Wordpress. However, I have set 2 MySQL databses. The first one is for WP only, while I use the second one for my custom application, which is integrated in WP.
Like said, I had the same structure and setup on Godaddy, where this was working.
I exported both db's on GoDaddy via phpMyAdmin and then imported them on Bluehost. All the site files were moved with FileZilla.
If I look at the new databases on Bluehost, they are utf8_general_ci encoded, which is ok. Also the website has utf8 in header, etc.
I have an interesting situation. Since I am from Slovenia, we have some special characters, like Č, Š, Ž, and small ones č, š, ž. The Wordpress content prints all these characters just fine, while I have problems printing these characters correctly from my second (application) database, You can see my problem on this link: http://www.slotenis.si/baza-igralcev/
Any ideas what could be wrong?
I tried the online chat support with Bluehost, but we couldn't solve it. Must say, they are very helpful, but were left out of ideas on this one.
Thanks,
Goran

Make your application set the character encoding of the DB connection to UTF-8 when it connects. How to do that depends on the API you use to access the database. In PDO for example you would add charset=utf8 to the connection string.

After several hours of Googling, I found the solution. I only need to add the following line after my connection string. I use mysqli...
$con = mysqli_connect("localhost","username","password","database") or die("Error " . mysqli_error($con));
**$con->set_charset("utf8");**
Now up and running. The credit for solution goes to:
http://webmonkeyuk.wordpress.com/2011/04/23/how-to-avoid-character-encoding-problems-in-php/

Related

Turkish character encoding cannot be interpreted properly

I have a database in which tables are of Turkish encoding as well as pages in which data is shown are of UTF-8 (I mean while saving as a file). However, as you can see in the second image, the page cannot interpret Turkish letters in the buttons. How can it be fixed? The buttons' texts come from the database. When I go to Teacher table, all is alright as expected, but on the page.
I have fixed lately the issue by setting the encoding property of mysqli in the connection page. Nonetheless, I don't know what is the default. It is genuinely interesting since there is no issue like that when I use MAMP db server on my localhost, but on the online server.
$mysqli = connect();
$mysqli->set_charset("utf8");

UTF8 lithuanian characters unrecognized in MySQL database

I have well known but quite difficult to sort out problem here. And yes I was searching on forum but those threads are old enough so I decided to create new post.
So I built a website using WP and included html FORM in one page. When user fills the form (in his/her language) the values of the fields' go into MySQL database table reg_form.
Everything works, the values are saved, BUT some characters (specific in that language) are not recognized. I tried a lot of different methods to solve this, but nothing can help.
The strangest thing is that if you look at WordPress tables you can find those specific characters are recognizable but not in reg_form table which I created.
I was trying to solve this problem and finally I decided to approach in somehow ridiculous way. I created NEW database, new tables, installed new wordpress, created new form etc.
That‘s what I was doing:
I used this suggestion first:
http://tympanus.net/codrops/2009/08/31/solving-php-mysql-utf-8-issues/
Yes, my files are saved using UTF8 encoding (without BOM). Yes, meta tags are ok. Yes, the FORM uses accept-charset='UTF-8'. Yes, all tables in database use UTF8. Yes, server, database and tables collation is the same “utf8_general_ci”.
Then I tried to insert in my code this:
$conn = mysql_connect($server, $username, $password);
mysql_set_charset("UTF8", $conn);
Then I tried this suggestion
link here: akrabat.com/php/utf8-php-and-mysql/
Then I tried to set Apache's AddDefaultCharset in .htaccess file using this link here: httpd.apache.org/docs/2.0/mod/core.html#AddDefaultCharset
BUT… still the problem remains. I can’t see those specific characters properly – only weird hieroglyphic.
The problem you face has to do with a little specific detail in database character encoding settings and Wordpress.
While Wordpress has a general character encoding setting that normally takes care about database tables as well, it does not care about the default character encoding setting of the database those tables are in.
So when your plugin/code adds a database table your own, you need to take care about the encoding settings as well - because by default they will be the database default you create the table in, which most likely is latin-1 which does not work well for your language.
To set the default character set for the database (replace "wpdb" with your database name if it varies):
ALTER DATABASE wpdb CHARACTER SET utf8 COLLATE utf8_general_ci;
To change the character set for your existing table *"reg_form"*:
ALTER TABLE reg_form CONVERT TO CHARACTER SET charset_name;
Note: Backup your database first.
HOLLY SHIT!! FINALLY! : ))))))))
The problem was that I was using mysqli_ queries. Now I tried to change to mysql_ (notice the change!) queries and it worked!! Two weeks of haaaaard working and researches... Phew!
Now who can explain me properly the reasons of this phenomena? : ))

Arabic Fonts Show As Question Marks After Editing Online

I created an Arabic website using PHP 5.3, MySQL 5 and PHPMyAdmin 3.4.
On every page, I use the "utf-8" character set. I include the following line on every page:
http://jsfiddle.net/Hh7mk/
The website works fine offline (on local server (localhost)). Even after I edited and inserted new Arabic writings into the database.
The problem is when the website is online. All Arabic fonts are displayed properly, but after I edited or inserted new Arabic writings into the database online, the new writings are displayed as question marks.
My settings (online):
PHPMyAdmin MySQL Connection Collation : utf8_general_ci.
PHPMyAdmin MySQL charset : UTF-8 Unicode (utf8).
The database and tables collation : utf8_general_ci.
In the connection file, I have included mysqli query SET NAMES 'utf8' and SET CHARACTER SET utf8.
I also have tried to change the collation to "cp1256_general_ci", and the pages character set to "windows-1256", but the fonts still show as question marks.
Why the Arabic fonts show as question marks after I inserted/ edited them online? How to fix this?
Thank you in advance
Have you tried using mysql_set_charset
mysql_set_charset("utf8");
seems you are doing everything right. but did you make all this before inserting data?. try cleaning up database and inserting from the scratch
The ASCII ? mark's code is 63 which is the first byte of all Arabic characters (each character has two bytes). Having your strings turned to ? means that only the first bytes of your characters are stored/retrieved. This is an indication that somewhere is your store/retrieve process you've got a bottleneck in which only ASCII characters can pass. My bet is on MySQL. The best way you can find this out is to use your local server's code (a local PhpMyAdmin shall do) connecting to your production server's MySQL. If the problem remains it shows that it's MySQL's configuration doing (considering the fact that your local PhpMyAdmin works fine with your local MySQL). I can only give you ideas on how to investigate the problem. You need to find the problem itself on your own.

Flex datagrid unicode characters

So i was asked to build a flex application to store clients for a local business. However it needs to store the clients using Greek characters. My problem is that when importing a name in the datagrid in Greek it work Λεωνίδας When i try to put it in the database using phpmyadmin it seems to be ok but then it comes like ??????????? in the datagrid. My set is flex application connecting to mysql using php services. I have setted the encoding of the database to be utf8-general with no luck. Im not sure if this is a problem with flex or with the services. Any ideas?
This forum discussion presents ideas for how to use special characters in Flash/Flex including Greek characters. See Kostas Zotos' post for a potential solution with these building blocks:
Use utf-8 encoding.
Use an xml file with a CDATA block to list greek characters.
Use device fonts, not embedded fonts.
So after a bit of research in greek flex and php forums i found out a solution. in order to access any utf8 language from flex the only thing that needs to be done is to add
mysqli_query($this->connection, "set names utf8");
before any sql statements in the methods of the service files (getAllSomething). This will allow to write and retrieve utf8 charsets in any language without a problem.
i hope this will be helpful to other flex developers as well.

remove weird characters

I have imported the wordpress database and full source and implemented in my local server. I started working on it and i have also updated the wordpress version and also the plugins.
now the problem is that there are weird characters coming in my posts. such as ’ instead of '.
So now shall i remove this from everywhere now. i have lots of posts and i dont want to do laborious work. can we have fire some query on wordpress database and remove this character..
Try to change the database collation to UTF-8-GENERAL
charset in MySQL

Categories