使用星号的 PHP/SQL SELECT 语句

发布于 2024-10-28 02:07:39 字数 922 浏览 1 评论 0原文

我无法让 sql 请求正常工作。无需提供超出需要的更多细节,

$db_query = mysql_query(" select years,avg,best,win,top10,champs from `profile` where PLAYERID = '$monkey_id'");

就可以正常工作。但是,

$db_query = mysql_query(" select * from `profile` where PLAYERID = '$monkey_id'");

不返回任何结果。唯一的变化是我试图提取所有字段,而不仅仅是那几个字段。我无法解释这一点。我自学了所有这些东西,所以我总是有可能做一些愚蠢的事情。

编辑: 这是周围代码的其余部分:

$db_query_inside = mysql_query(" select * from `profile` where PLAYERID = $monkey_id");
$db_query = mysql_fetch_array($db_query_inside);
$years_prev = $db_query['years'];
$avg_prev = $db_query['avg'];
$best_prev = $db_query['best'];
$win_prev = $db_query['win'];
$top10_prev = $db_query['top10'];
$champs_prev = $db_query['champs'];

再次编辑: 仍然不知道为什么它不能与 * 一起使用,但我只是通过列出特定字段来完成我需要的工作。它最终不会产生任何可以从中收集到的错误,

die(mysql_error())

所以我只是放弃并致力于做出理性反应的事情。

I am having trouble getting an sql request to work. Without giving more details than needed,

$db_query = mysql_query(" select years,avg,best,win,top10,champs from `profile` where PLAYERID = '$monkey_id'");

works fine. However,

$db_query = mysql_query(" select * from `profile` where PLAYERID = '$monkey_id'");

doesn't return any results. The only change is that I'm trying to pull all fields instead of just those few. I'm at a loss to explain this. I taught myself all this stuff, so it's always possible I'm doing something dumb.

Edit:
Here's the rest of the surrounding code:

$db_query_inside = mysql_query(" select * from `profile` where PLAYERID = $monkey_id");
$db_query = mysql_fetch_array($db_query_inside);
$years_prev = $db_query['years'];
$avg_prev = $db_query['avg'];
$best_prev = $db_query['best'];
$win_prev = $db_query['win'];
$top10_prev = $db_query['top10'];
$champs_prev = $db_query['champs'];

Edit again:
Still don't know why it wouldn't work with *, but I just got what I needed done by listing the specific fields. It doesn't end up with any sort of error that can be gleaned from

die(mysql_error())

so I'm just giving up and working on stuff that reacts rationally.

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

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

发布评论

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

评论(2

难理解 2024-11-04 02:07:39

为什么不尝试:

$db_query = mysql_query(" select `profile` where PLAYERID = '$monkey_id'");

Why not try:

$db_query = mysql_query(" select `profile` where PLAYERID = '$monkey_id'");
花桑 2024-11-04 02:07:39

让我们这样做,修改以下行以反映如下。查看错误内容(如果有)。我自己尝试过(你的代码),它似乎工作得很好。

$db_query_inside = mysql_query(" select * from `profile` where PLAYERID = $monkey_id") or die(mysql_error());

Let's do this, modify the following line to reflect below. See what the error says, if any. I tried it myself (your code) and it seems to work fine.

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