Solved

PHP - diamond question mark

Posted on 2010-09-02
6
496 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
Comment Utility
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 82

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 100 total points
Comment Utility
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
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 3

Expert Comment

by:swesluggo
Comment Utility
damn phone.. now i was late again!
0
 
LVL 16

Author Comment

by:carsRST
Comment Utility
encoding in the database says "latin1"

Do I put this in my PHP connection code?

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

Expert Comment

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

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

762 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now