The reason may be: PHP for the ntext type of MSSQL support problem;
Today, you can link to the database, but cannot read the data. Google, Baidu After finally know, the original is the PHP read MSSQL ntext field back value is empty, we suggest that the ntext field can be changed to text.
If there is no ntext field in the table, you can use the following code:
<?php Connect to MSSQL $link = Mssql_connect (' kallespc\sqlexpress ', ' sa ', ' phpfi ');
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:
To
Mssql.textlimit = 2147483647 |
Found it:
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, so PHP can get a wrong time reading with ntext and nvarchar type fields through MSSQL extensions.
If the Title field type is nvarchar,content field type is ntext, the following SQL statement complains:
Wrong:
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.
<?php Include ("adodb/adodb.inc.php"); Contains ADODB class library files $conn =newadoconnection (' Odbc_mssql '); Connecting to SQL Server databases $conn->connect ("Driver={sql Server}"; Server=localhost;database=mydb; ", ' username ', ' password '); ?> |