使用星号的 PHP/SQL SELECT 语句
我无法让 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为什么不尝试:
Why not try:
让我们这样做,修改以下行以反映如下。查看错误内容(如果有)。我自己尝试过(你的代码),它似乎工作得很好。
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.