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
Share on other sites

- Please be conscious of where you post, I moved your thread to the correct section.

- Read the forums rules and section descriptions before creating a thread!

- In the future, please place


tags around your code.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.