views:

24

answers:

2

Hello,

I am trying to display some information from SQL Server to my PHP site. I am using ODBC connection for that one.

My Issue is : Special characters are not recognised and it is displaying "question mark (?)" in my site. (This works in my other ASP site)

What I am missing here ? Please help me.

Thanks in advance.

A: 

What's your character encoding for the ODBC connection? It should be some UTF with proper handling on PHP side...

BarsMonster
Hi, I am not using any UTF encoding for now. Below is my code...function get_odbc_connection(){ $myServer = "Driver={SQL Server};Server={server_ip_address};Database={database_name}"; $myUser = "{username}"; $myPass = "{pwd}"; $myDB = "{database_name}"; // create connection $connection = odbc_connect($myServer,$myUser,$myPass,SQL_CUR_USE_ODBC); // test connection if (!$connection) { echo "Couldn't make a connection!"; exit; } else { return $connection; }}
aayushi
+1  A: 

Hi, I use some special MSSQL query converter and then ICONV in the PHP side like this:

   SELECT  CAST(Remarks AS TEXT) Remarks FROM r_table;

And in the PHP, say the text is in CodePage 1255:

   iconv('CP1255', 'UTF-8', $remark);

hope that's helps.

aviv
Hi Aviv.. it works !!! Many Many Thanks. :-)
aayushi
So vote for it ;-) and mark it as an answer
aviv