if your sql server use ANSI encoding and your page use UTF-8, this is method to convert to UTF-8
<?php
function convertAnsi2UTF8($array){
foreach ($array as $key=>$item) {
if(is_array($item)) $array[$key]=convertAnti2UTF8($item);
else $array[$key]=iconv("TIS-620","UTF-8",$item);
}
return $array;
}
?>
Microsoft SQL Server
- Introduction
- Installing/Configuring
- Predefined Constants
- Mssql Functions
- mssql_bind — Adds a parameter to a stored procedure or a remote stored procedure
- mssql_close — Close MS SQL Server connection
- mssql_connect — Open MS SQL server connection
- mssql_data_seek — Moves internal row pointer
- mssql_execute — Executes a stored procedure on a MS SQL server database
- mssql_fetch_array — Fetch a result row as an associative array, a numeric array, or both
- mssql_fetch_assoc — Returns an associative array of the current row in the result
- mssql_fetch_batch — Returns the next batch of records
- mssql_fetch_field — Get field information
- mssql_fetch_object — Fetch row as object
- mssql_fetch_row — Get row as enumerated array
- mssql_field_length — Get the length of a field
- mssql_field_name — Get the name of a field
- mssql_field_seek — Seeks to the specified field offset
- mssql_field_type — Gets the type of a field
- mssql_free_result — Free result memory
- mssql_free_statement — Free statement memory
- mssql_get_last_message — Returns the last message from the server
- mssql_guid_string — Converts a 16 byte binary GUID to a string
- mssql_init — Initializes a stored procedure or a remote stored procedure
- mssql_min_error_severity — Sets the minimum error severity
- mssql_min_message_severity — Sets the minimum message severity
- mssql_next_result — Move the internal result pointer to the next result
- mssql_num_fields — Gets the number of fields in result
- mssql_num_rows — Gets the number of rows in result
- mssql_pconnect — Open persistent MS SQL connection
- mssql_query — Send MS SQL query
- mssql_result — Get result data
- mssql_rows_affected — Returns the number of records affected by the query
- mssql_select_db — Select MS SQL database
Mssql
hlex dot hlex at gmail dot com
27-Jun-2009 05:04
27-Jun-2009 05:04
opc dot three at gmail dot com
02-Jun-2009 03:50
02-Jun-2009 03:50
After extensive research trying to get PHP on Linux communicating with SQL Server 2005 and 2008 including support for all Unicode, MAX and XML data types I could not find any open source solutions...yes, I spent a lot of time trying to get FreeTDS to work to no avail.
I found one free solution that runs on Windows which is to use the "SQL Server Driver for PHP" provided by Microsoft (http://sql2k5php.codeplex.com). The driver relies on the Microsoft Native Client ODBC drivers for SQL Server 2008 (part of the "Microsoft SQL Server 2008 Native Client" which is downloadable from Microsoft) which is why this solution will not work on anything except Windows.
I did find a solution that works for PHP on Linux but it's not free...use the standard PHP::ODBC lib (free) and the Easysoft ODBC driver for SQL Server (not free, but reasonable by Enterprise standards). You can check out the ODBC driver by going here http://www.easysoft.com/products/data_access and looking for "Easysoft ODBC-SQL Server Driver"
thanhha dot phan at yahoo dot com
04-May-2009 02:03
04-May-2009 02:03
I got a serious problem with Unicode data when working with PHP and MSSQL. I have to say the PHP and MSSQL doesn't seem to be a good combination.
MSSQL is really complicated to work with since the whole server uses a single character encoding[ucs-2]. In order to store unicode information, the column data types must be specified as one of the national character types, NVARCHAR, NCHAR or NTEXT.
In order to retrieve data saved in unicode format, M$ suggest users to cast columns to binary data.Unfortunately php_mssql extension doesn't support binary data to be returned in string columns.
My advice is to use FreeTDS driver [it's just an php extension]. This driver seems to handle unicode data better. I can put and receive unicode with casting or change encoding.
A good tutorial "Using freeTDS" can be found here
http://docs.moodle.org/en/Installing_MSSQL_for_PHP
However, freeTDS is not a perfect solution for unicode data. I'm not able to execute stored procedures with mssql_bind, mssql_bind without having my text changed.
AA
11-Mar-2009 08:26
11-Mar-2009 08:26
On windows, do not use this for mssql 2005 of later. The methods of access are deprecated.
Use the Microsoft SQL Server 2005 Driver for PHP instead.
Current link is.
http://www.microsoft.com/sqlserver/2005/en/us/PHP-Driver.aspx
