|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
insert unicode data to MSSQL via web form
Hi Guyz,
Anyone one know is it possible to insert unicode code data into MSSQL 2000 via web forms using PHP? I got a problem with that. The inserted data becomes some special characters or ???. Here is my system info: Platform: Windows 2000 (Traditional Chinese) WebServer: Apache 3.x Database: MSSQL 2000 (Default collation: Chinese_Taiwan_Stroke_CI_AS) PHP: v4.0.5 DB Connection method: through ODBC My Codes: - a simple HTML form using CHARSET UTF-8: ----------------------------------------------- <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <form name="myform" method="post" action="insert.php"> <input name="text" type="text"> <input name="submit" type="submit"> </form> ----------------------------------------------- - INSERT.PHP for inserting data into MSSQL via ODBC ------------------------------------------------ if (! $conn = odbc_connect("TEST","sa","sapass")) echo "CONN FAIL"; $stmt = "INSERT INTO NEWTB (MYID, MYFILE) VALUES ('1', '" . $text . "')"; if (odbc_exec( $conn, $stmt)) echo "ok"; else echo "fail!"; ------------------------------------------------ - READ.PHP, script for selecting data from MSSQL ------------------------------------------------ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <table> <? if (! $conn = odbc_connect("TORTEST","sa","")) echo "CONN FAIL"; $stmt = "SELECT MYID, MYFILE FROM NEWTB"; $cur = odbc_exec( $conn, $stmt); while(odbc_fetch_row( $cur )) { $myID = odbc_result( $cur, 1 ); $myFile = odbc_result( $cur, 2 ); $myText = odbc_result( $cur, 3 ); echo "<tr><td>$myID </td><td>$myFile</td><td>$myText</td></tr>n"; } ?> </table> ------------------------------------------------ - Here is the schema of DB Table NEWTB MYID INT MYFILE NVARCHAR(100) ( Collation: Chinese_Taiwan_Stroke_BIN ) MYTEXT NTEXT(16) ( Collation: Chinese_Taiwan_Stroke_BIN ) ------------------------------------------------ Anyone got a working solution or any idea on this? |
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Database Help > insert unicode data to MSSQL via web form |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|
|