remove weird characters - php

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

Related

Joomla 3.8.2 wrong character encoding

My website is showing the wrong characters as you can see in the attached image, taken from google analytics:
Now, the problem is that these characters only show SOMETIMES, which I find very strange.
I've tried changing the database collation to utf-8 as per this post.
And I've also tried using Admin tools "Change database collation" several times, and "Repair & Otimise tables" but nothing works.
Have also cleared cache and temp directory.
Can anyone please help?

Bluehost MySQL Country Specific Characters Encoding

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/

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.

UTF8 doesn't get parsed by php, server related ? not file related

this is so weird, this has never happened to me. I've worked with utf-8 alot and this is the first time happening,
Since last week all my sites that had utf8 characters in files are now showing ? instead of the actual character!
the files are ok and I can see characters fine if I edit them,but after it gets processed by php it changes the utf-8 characters with ?.
the utf8 characters that were stored in database are loading just fine , but the problem is with the strings that are in php files.
Notice I said since last week, this means it happened all of a sudden and obviously something changed on server.
I contacted my hosting company but they have no clue what to look for and I don't know what to tell them to look for.
any clue what could have been changed on the server?
so to conclude:
it's not a database problem
it's not a file encoding problem (I hope not, I have 30+ sites with different cms on each one, can not afford to edit them all)
it's not a content-type issue in html because it's getting parsed by php and turns utf8 characters to ?
it could alse be a wordpress problem,but I'm sure this happend after some changes on server side
screenshot1
screenshot2
it's not a database problem - Check
it's not a file encoding problem - THIS actually could be it
it's not a content-type - Check (but make sure you write UTF-8 in meta tag lowercase !)
Wordpress problem - Maybe with combination of file encoding
I can imagine situation, when you deleted/disabled mb_string module for PHP and then edited your template using wordpress. Then your characted got shattered.

Categories