The result is that there is no ntext field in the table, you can use the following code:
The code is as follows |
Copy Code |
<?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 of 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 has a ntext army field, and it is not good to modify back to the Text field, you can do the following:
1. Modify PHP.ini
Open php.ini
Found it:
The code is as follows |
Copy Code |
; mssql.textlimit = 4096 To Mssql.textlimit = 2147483647 Found it:
; mssql.textsize = 4096 To
Mssql.textsize = 2147483647
|
2. You can use the Modify field, because the ntext and nvarchar fields in SQL Server store content in Unicode encoding.
As a result, PHP can get a mistake when reading a field with ntext and nvarchar types through the MSSQL extension.
If the Title field type is nvarchar,content field type is ntext, the following SQL statement complains:
Wrong:
The code is as follows |
Copy Code |
Select Title,content from article The 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. If you do not support the host, the author is also no way.
code is as follows |
copy code |
<?php Include ("adodb/adodb.inc.php"); Contains the ADODB class library file $conn =newadoconnection (' odbc_mssql ');//Connect SQL Server database $conn->connect ("Driver={sql Server }; Server=localhost; Database=mydb;, ' username ', ' password '); |