Solved

PHP - diamond question mark

Posted on 2010-09-02
6
503 Views
Last Modified: 2013-12-13
PHP/MySQL app.  Some data coming back as the diamond question mark.

How to eliminate?
0
Comment
Question by:carsRST
6 Comments
 
LVL 2

Accepted Solution

by:
IngCharlie earned 200 total points
ID: 33589626
Check encoding on your database connection and your php script

After You connect to the database set the connection encoding here's an example:

            switch ($site_encoding)
                  {
                        case("cp1250_general_ci"):
                            mysql_query("SET character_set_client = cp1250 ");
                            mysql_query("SET character_set_results  = cp1250 ");
                            mysql_query("SET collation_connection = cp1250_general_ci");      
                        break;
                        case("latin2_czech_cs"):      
                              mysql_query("SET character_set_client = latin2 ");
                              mysql_query("SET character_set_results  = latin2 ");
                              mysql_query("SET collation_connection = latin2_czech_cs");
                        break;      
                        default:
                                 mysql_query("SET character_set_client = utf8 ");
                            mysql_query("SET character_set_results  = utf8 ");
                            mysql_query("SET collation_connection = utf8_slovak_ci");
                        break;      
                  };
0
 
LVL 83

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 100 total points
ID: 33589683
That is usually a character set / encoding mismatch between the data and the page that displays it.  You need to make sure that they are the same.
0
 
LVL 3

Assisted Solution

by:swesluggo
swesluggo earned 200 total points
ID: 33589706
kinda hard to say, but im guessing either the the encoding in your presentation layer (probably your browser) or in your db is wrong.. to switch in your browser you just select something like page > encoding > unicode/utf8 or whatever it calls it. if its in your db you need to convert the field(s) that are returning funky data.. this is done by first changing them into binary and then switching to utf-8 (which cover most chars) eg
alter table <tabkename> modify <columnname> binary(<fieldsize>);
alter table <tablename> modify <columnname> <fieldtype>(fieldsize>) character set utf8;
0
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
LVL 3

Expert Comment

by:swesluggo
ID: 33589722
damn phone.. now i was late again!
0
 
LVL 16

Author Comment

by:carsRST
ID: 33590715
encoding in the database says "latin1"

Do I put this in my PHP connection code?

mysql_query("SET character_set_results  = latin1 ");
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 33591900
What the character set for the page that you're displaying it on?
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question