I apologize for the stupid question, I know that the topic has been cheated a hundred thousand times, but I cannot find a mistake here. In mysql, I do not experience such problems, mssql is not my choice, but you need to implement it. Tell me what I'm doing wrong, there is a config.php file that I connect to all scripts as standard. I set the coding by request so

sqlsrv_query($conn,'set names cp1251'); 

or so:

 sqlsrv_query($conn,'SET NAMES utf8'); 

where $ conn is the connection to the server. But both options do not help. Everything would be fine, but when outputting from MSSQL, question marks are displayed in the browser, instead of Cyrillic. Google, that it is necessary to specify in MSSQL to a kajdy column

 COLLATE Cyrillic_General_CI_AS 

Actually all the columns put down, but the question marks at the conclusion does not disappear.

  • And the type of columns in the table, apparently, varchar ? Change to nvarchar . - Yaant
  • changed to nvarchar - did not help, as suggested below, $ var = iconv ('UTF-8', 'windows-1251', $ _ GET ['project_manager']) began to use for saving files; and then I give $ var to the request, it is inserted in the database as if it’s correct, there are no question marks, but on the output all the same characters ???. I try on the output request, do the opposite: $ var = iconv ('windows-1251', 'UTF-8', $ arr ['project_manager']); I receive in the answer - Р¤РРћР¤РРћ and on the page it is still signs ???. - Igor Tyulkin

1 answer 1

MSSQL server stores data in windows-1251, so if your php file is in utf-8 encoding, then when inserting into the database you need to change the encoding of your variables from utf-8 to windows-1251 using the iconv function. Also, you will need to change the encoding in the opposite direction when retrieving data from the database. As an option, you can change the encoding of the php file, but most likely it will result in problems as now everything on the web is directed to utf-8.

  • began to save files using $ var = iconv ('UTF-8', 'windows-1251', $ _ GET ['project_manager']); and then I give $ var to the request, it is inserted in the database as if it’s correct, there are no question marks, but on the output all the same characters ???. I try on the output request, do the opposite: $ var = iconv ('windows-1251', 'UTF-8', $ arr ['project_manager']); I receive in the answer - Р¤РРћР¤РРћ and on the page it is still signs ???. - Igor Tyulkin
  • in notepade ++ look in what encoding your page has, if not in utf-8 then convert to utf-8 without bom - heff
  • Thank you very much! - Igor Tyulkin