The solution for php to read the ntext field of mssql to return null is mssqlntext. The solution for php to read the ntext Field returned value of mssql is null. mssqlntext this article describes the solution for php to read the ntext Field returned value of mssql. For your reference, please refer to the solution in which php reads the ntext field of mssql and the returned value is null.
The example in this article describes how php can read the ntext field of mssql and return null values. Share it with you for your reference. The specific analysis is as follows:
When using php to connect to the mssql database today, the content of the ntext field cannot be displayed. After query, it is found that the ntext field is not supported in php, the solution is to change the ntext field to text.
If there is no ntext field in the table, use the following code:
The code is as follows:
<? Php
// Connect to MSSQL
$ Link = mssql_connect ('kallespcsqlexpress ', 'sa', 'dsc ');
If (! $ Link |! Mssql_select_db ('php', $ link ))
{
Die ('unable to connect or select database! ');
}
// Do a simple query, select the version
// MSSQL and print it.
$ Version = mssql_query ('select @ version ');
$ Row = mssql_fetch_array ($ version );
Echo $ row [0];
// Clean up
Mssql_free_result ($ version );
?>
If the table contains the ntext field and it is difficult to modify the text field, you can:
1. modify php. ini, open php. ini, and find the following code:
; Mssql. textlimit = 4096 to mssql. textlimit = 2147483647
Locate:; mssql. textsize = 4096 to mssql. textsize = 2147483647
2. you can modify fields. because ntext and nvarchar fields in SQL server are stored in unicode encoding, an error is reported when php reads fields with ntext and nvarchar types through mssql extension.
If the title field type is nvarchar and the content field type is ntext, the following SQL statement reports an error.
The error code is as follows: select title, content from article
Correct:
Select convert (varchar (255), title) as title, convert (text, content) as content from article
3. if you are a virtual host, you can use the adodb component to read it. if your host does not support it, the author cannot read it now. the code is as follows:
The code is as follows:
<? Php
Include ("adodb/adodb. inc. php"); // contains the adodb class library file
$ Conn = NewADOConnection ('odbc _ mssql'); // connect to the SQL Server database
$ Conn-> Connect ("Driver = {SQL Server}; Server = localhost;
Database = mydb; ", 'username', 'password ');
?>
I hope this article will help you with php programming.
Examples in this article describes how php can read the ntext field of mssql and return null values. Share it with you for your reference...