Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I highly recommend you to stop using php_mssql, instead get <code>Microsoft Drivers for PHP for SQL Server</code> and almost any problems that we have in php_mssql will be solved, you will have <strong>a lot of troubles</strong> in sending and getting UTF-8 data to and from SQL Server using php_mssql.</p> <p>You will have to CAST nText and nVarchar while selecting to Text and Varchar because php_mssql only support old SQL Server drivers ...</p> <p>If you really need to use php_mssql, you have to use <code>iconv</code> and maybe <code>utf8_decode</code>. Here are 2 functions that I wrote to store and get UTF-8 Persian/Arabic data in SQL Server.</p> <pre><code>function persian_sql_to_php($str){ if(mb_detect_encoding($str) == 'UTF-8' AND mb_check_encoding($str, 'UTF-8')){ $str = utf8_decode($str); } $str = iconv('Windows-1256', 'UTF-8', $str); return $str; } function persian_php_to_sql($str){ $str = iconv('UTF-8', 'Windows-1256', $str); return $str; } </code></pre> <p>You will need to change Windows-1256 to something else depending on the language you are using. Also try <code>utf8_decode</code> and <code>utf8_encode</code> alone, maybe they work for your case.</p> <p><strong>Update:</strong></p> <p>Since you are using FreeTDS, the situation maybe differ a little from main php_mssql that I explained above about it's problems with UTF-8 ...</p> <p><strong>Update 2:</strong> I just tried this code on Windows and it seems to work, can you try it too, maybe it works for you too?</p> <pre><code>&lt;?php mssql_connect('127.0.0.1', 'sa', '123456'); mssql_select_db('test'); $val = 'café'; $val = iconv('UTF-8', 'ISO-8859-1', $val); mssql_query('INSERT INTO mytest (test) VALUES (\''.$val.'\');'); ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload