簡體   English   中英

PHP SQL 服務器錯誤跟蹤

[英]PHP SQL Server error tracking

我正在使用眾所周知的 function mysql_error跟蹤 mysql 錯誤。 但是,我正在從 SQL 服務器訪問記錄,為此我使用了 PHP 提供的所有mssql_函數。

我的一個查詢沒有被執行,我不確定我在哪里做錯了。 誰能告訴我,SQL 服務器跟蹤數據庫錯誤的確切 function 是什么(在 PHP 中可用)。

SELECT * FROM gb WHERE postalcode like 'YO1%' OR place like 'YO1%' group by postalcode, region3 order by postalcode asc

不幸的是,SQL 服務器中沒有錯誤 function。 相反,使用mssql_get_last_message()

這是一個簡單的 select sql。 如果我是你,我想在 SQL Server Management Studio 中運行它。 除此之外,請嘗試此鏈接http://www.php.net/manual/en/function.mssql-get-last-message.php#21728 ,其中有人嘗試使用通用錯誤處理存儲過程解決問題。

SELECT * FROM gb WHERE postalcode like 'YO1%' OR place like 'YO1%' group by postalcode, region3 order by postalcode asc

這永遠不會起作用,因為您使用的是 GROUP BY 子句。 您需要指定要顯示的字段。 所以像:

SELECT
    postalcode, region3
FROM
    gb
WHERE
    postalcode LIKE 'YO1%' OR place LIKE 'YO1%'
GROUP BY 
    postalcode, region3
ORDER BY 
    postalcode ASC

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM