PHP SQL Server 错误跟踪
我正在使用大家都知道的函数 mysql_error
来跟踪 mysql 错误。但是,我正在从 SQL Server 访问记录,为此我使用了 PHP 提供的所有 mssql_
函数。
我的一个查询没有被执行,我不确定我在哪里犯了错误。谁能告诉我,SQL Server 跟踪数据库错误的确切函数是什么(在 PHP 中可用)。
SELECT * FROM gb WHERE postalcode like 'YO1%' OR place like 'YO1%' group by postalcode, region3 order by postalcode asc
I am tracking mysql errors using the function mysql_error
that everyone knows. But, I am accessing records from SQL Server, For that i have used all the mssql_
functions which are provided by PHP.
One of my queries is not getting executed and am not sure where i did the mistake. Can any one please tell me, what is the exact function for SQL Server to track the DB errors(available in PHP).
SELECT * FROM gb WHERE postalcode like 'YO1%' OR place like 'YO1%' group by postalcode, region3 order by postalcode asc
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不幸的是,SQL Server 中没有错误函数。相反,请使用
mssql_get_last_message()
。Unfortunately, there is no error function in SQL Server. Instead, use
mssql_get_last_message()
.这是一个简单的选择sql。如果我是你,我想在 SQL Server Management Studio 中运行它。除此之外,请尝试此链接 http:// www.php.net/manual/en/function.mssql-get-last-message.php#21728 其中有人尝试使用通用错误处理存储过程解决问题。
This is a simple select sql. I would want to run this in SQL Server Management Studio, if I were you. Apart from that, try this link http://www.php.net/manual/en/function.mssql-get-last-message.php#21728 where someone has tried to resolve issues using a GENERIC ERROR HANDLING Stored Procedure.
这永远行不通,因为您正在使用 GROUP BY 子句。您需要指定要显示的字段。所以像这样:
This can never work, as you are using the GROUP BY clause. You will need to specify which fields to show. So something like: