Jump to content

Unicode php mssql


wpoprovider

Recommended Posts

Hi,

 

I have been working with inserting unicode characters into mssql database from a php application.

 

My php web application displays the chinese characters as i entered and retrieves from database properly. But when I take a look at the database the fields are populated with some other values other than the characters i inserted.

 

When i developed the same application in ASP.net the database has correct values inserted into it.

 

Here is my code in php:

 

<?php

// direct insert
$var = mssql_connect('RAL-DEV-SQL01','TestDBSa','TestDB$@');

$selected = mssql_select_db('TestDB', $var);


$myVar="日常生活";


$myChineseVar=$myVar;
echo $myChineseVar;


$query = "insert into TestChinese (TestName) values (N'{$myChineseVar}')"; 

$result = mssql_query($query,$var);

echo "Inserted<br>";
echo $query;


echo "<br>Result<br>";
$result2 = mssql_query("SELECT TOP 10 * FROM [TestChinese] order by SeqNum desc",$var);
while($nt=mssql_fetch_array($result2)){
echo "$nt[seqNum] - "."$nt[TestName] -";

echo "<br>";

} 

mssql_close($var);

?>

 

Can someone help me with this problem

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/237537-unicode-php-mssql/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.