API连接到mysql有时不执行查询
我的一个非常令人困惑和疲惫的问题:
我开发了一个 API 来允许其他人从我的数据库中提取信息。我的服务器收集 POSTed 信息,编写 mysql 查询,执行查询 [$query = mysql_query($string, $connection);] ,并返回结果(非常简单)。
问题是有时(比如每 5 次尝试中有 1 次)没有返回任何信息。我的服务器日志显示资源($query)是布尔值(因此没有结果)。我的服务器每次都会收到来自 API 远程用户的信息,问题似乎是我的查询有时只是没有被执行......
为什么会发生这种情况?
是mysql性能问题吗?对于在我自己的页面上进行的查询(即不是来自 API),我似乎从未有过任何性能问题的暗示!
请帮忙...
a very puzzling and exhausting problem of mine:
I developed an API to allow others to draw information from my database. My server collects the POSTed info, writes up a mysql query, performs the query [$query = mysql_query($string, $connection);] , and returns the results (very simple).
the problem is that sometimes (say 1 out of every 5 tries) no info is returned. My server logs say that the resource ($query) is boolean (and therefore no results). My server receives the info from the remote users of the API every single time, the problem seems to be that my queries are sometimes just not being performed...
Why is this happening?
Is it a mysql performance issue? I never seem to have even a hint of a performance issue for queries made on my own page (i.e. not from the API)!
please help...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的查询可能会失败。尝试这样做:
如果查询生成异常/错误,它将停止脚本并显示 MySQL 错误。使用该错误,您可以修复查询,以便最终一切正常。
顺便说一句,您正在使用 $string,但使用 $builtQuery 可能是一个更好的主意,因为如果您稍后需要编辑脚本,“string”可能会令人困惑。
问候。
Your query might be failing. Try doing this:
If the query is generating an exception/error, it will stop the script and display the MySQL error. Using that error, you can fix your query so that everything will work fine eventually.
By the way, you are using $string, but it might be a better idea to use $builtQuery, because "string" might be confusing if you are going to need to edit the script later on.
Greetings.