0

In SQL 2008, in a nvarchar type column I have a string, "Connects students’ prior knowledge, life experiences, and interests in the". When I look at the string in the database it looks correct. When I echo that string in php it returns, "Connects students? prior knowledge, life experiences, and interests in the". It replaces the single quote with a question mark. Can someone please explain why that is happening?

Sorry if this is a stupid question.

EDIT: PHP Source File Encoding: UTF-8
SQL Collation: SQL_Latin1_General_CP1_CI_AS
Web page encoding: <meta charset="utf-8">

Nathan
  • 59
  • 1
  • 14
  • Differences between character encodings? – Havelock Oct 24 '13 at 10:33
  • Not that I'm aware of. How could I confirm this? – Nathan Oct 24 '13 at 10:34
  • DB encoding <-> PHP source file encoding <-> encoding of the web page you're echoing at – Havelock Oct 24 '13 at 10:37
  • Did you set charset using: `ini_set('mssql.charset', 'UTF-8');`? Some answers here might be helpfull: http://stackoverflow.com/questions/1322421/php-sql-server-how-to-set-charset-for-connection – piotrekkr Oct 24 '13 at 13:32
  • @piotrekkr Where would you suggest I put that ini_set? Would that go in my mssql query class, or on the page that is displaying the text? – Nathan Oct 25 '13 at 01:56
  • @Havelock Check my edit for the types of encoding happening in my code. – Nathan Oct 25 '13 at 01:57
  • @Nathan `collation` and `character set` are [two different things](http://stackoverflow.com/questions/341273/what-does-character-set-and-collation-mean-exactly/) – Havelock Oct 25 '13 at 07:16
  • @Nathan If you use utf8 application wide then I think that best place to use `ini_set()` it is in your bootstrap code, probably in `index.php`. It must be set before connecting to mssql. – piotrekkr Oct 25 '13 at 08:35

0 Answers0