Solved

PHP - diamond question mark

Posted on 2010-09-02
6
507 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 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
Raise the IQ of Your IT Alerts

From IT major incidents to manufacturing line slowdowns, every business process generates insights that need to reach the people required to take action. You need a platform that integrates with your business tools to create fully enabled DevOps toolchains.

You need xMatters.

 
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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
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 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 …

691 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