mysql_query 返回布尔值还是字符串?

发布于 2024-12-25 03:00:07 字数 398 浏览 1 评论 0原文

由于某种原因,当我运行应该返回要使用 mysql_fetch_array 解析的数组的 $result=mysql_query(...) 时,我不断收到返回值的错误for $result 是字符串或布尔值,mysql_fetch_array() 无法使用它。多年来我一直在我的服务器上运行相同的查询,但由于某种原因它最近停止工作。

这是示例代码:

$result=mysql_query("SELECT * FROM `patient_list`");
while ($row=mysql_fetch_array($result)) {
...
}

我最近升级到了最新版本的 wamp。这可能有什么关系吗?有什么想法吗?

For some reason when I run a $result=mysql_query(...) that should return an array to be parsed with mysql_fetch_array, I keep getting an error that the value returned for $result is either a string or boolean, which mysql_fetch_array() can't work with. I've been running the same query on my server for years and for some reason it stopped working recently.

here's the sample code:

$result=mysql_query("SELECT * FROM `patient_list`");
while ($row=mysql_fetch_array($result)) {
...
}

I recently upgraded to the newest version of wamp. might that have anything to do with it? Any thoughts?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

狂之美人 2025-01-01 03:00:07

此错误意味着 mysql_query 的结果无效。请

echo mysql_error(); 

在调用 mysql_query 之后放置

This error means taht result of mysql_query is not valid.Please place

echo mysql_error(); 

after you call mysql_query

甜警司 2025-01-01 03:00:07

您的问题可能是访问/数据库不存在/任何内容

始终检查查询运行是否正确执行您的查询,如下所示:

$result = mysql_query(<query>);
if (!$result) {
    die('Invalid query: ' . mysql_error());
}

// process the result here

mysql_query 文档

Your problem could be access / database doesn't exist / anything

Always check the query runs correctly execute your query like this :

$result = mysql_query(<query>);
if (!$result) {
    die('Invalid query: ' . mysql_error());
}

// process the result here

Documentation for mysql_query

悲喜皆因你 2025-01-01 03:00:07

试试这个:

$result = mysql_query("SELECT * FROM `patient_list`") or die( mysql_error() );

Try this:

$result = mysql_query("SELECT * FROM `patient_list`") or die( mysql_error() );
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文