?
Solved

PHP - diamond question mark

Posted on 2010-09-02
6
Medium Priority
?
508 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 2

Accepted Solution

by:
IngCharlie earned 800 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 84

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 400 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 800 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
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
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 84

Expert Comment

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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

764 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