我試圖在PHP中查詢連接並從MSSQL EXPRESS(2008 R2)數據庫中提取數據。但是當我從數據庫中提取基於ntext的數據時,出現錯誤。PHP中的MSSQL查詢問題和查詢文本數據
錯誤是;
僅Unicode編輯或ntext數據中的Unicode數據無法發送到使用DB-Library(如ISQL)或ODBC版本3.7或更低版本的客戶端。在
和我的腳本(嚴重性16)
$myServer = ".\SQLEXPRESS";
$myUser = "sa";
$myPass = "blablabla";
$myDB = "test";
//connection to the database
$dbhandle = mssql_connect($myServer, $myUser, $myPass)
or die("Couldn't connect to SQL Server on $myServer");
//select a database to work with
$selected = mssql_select_db($myDB, $dbhandle)
or die("Couldn't open database $myDB");
//declare the SQL statement that will query the database
$query = "SELECT * FROM dbo.table WHERE query='2'";
//$query .= "FROM dbo.table ";
//$query .= "WHERE query='2'";
//execute the SQL query and return records
$result = mssql_query($query);
$numRows = mssql_num_rows($result);
echo "<h1>" . $numRows . " Row" . ($numRows == 1 ? "" : "s") . " Returned </h1>";
//display the results
while($row = mssql_fetch_array($result))
{
echo "<li>" . $row["query"]. "</li>";
}
//close the connection
mssql_close($dbhandle);
有這方面的幫助表示讚賞....
感謝....
aww man you are awesome !!!它完美的作品!搖滾男人!!!!!!! – megazoid 2011-03-24 05:09:15
@megazoid哪種方法適合你(後代)? – Phil 2011-03-24 05:13:58
CAST(field1 AS TEXT)AS field1 – megazoid 2011-03-24 05:26:58