mysql 查询不工作,没有任何错误

发布于 2024-11-11 01:21:34 字数 270 浏览 0 评论 0原文

      $result53543534 = mysql_query("UPDATE users SET credit=credit+1 WHERE email= '{$battle_get['username']}'")
or die(mysql_error());

但不更新。检查了 $battle_get['username'] 并且用户名就在那里。 我没有收到任何错误或任何未添加的内容...

任何帮助将非常好,提前致谢

      $result53543534 = mysql_query("UPDATE users SET credit=credit+1 WHERE email= '{$battle_get['username']}'")
or die(mysql_error());

But does not update. checked $battle_get['username'] and the username is in there.
i am not getting any errors or anything just not adding...

Any help would be very nice thanks in advance

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

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

发布评论

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

评论(7

戏舞 2024-11-18 01:21:34

查看 mysql_affected_rows() 是:

if ( ! $result53543534 = mysql_query( "UPDATE users SET credit=credit+1 WHERE email= '{$battle_get['username']}'") ) {
    die( mysql_error() );
} else {
    echo "Number of rows affected: " . mysql_affected_rows() . "<br>";
}

我的语法可能不完全正确,但我希望你明白。如果结果为 0,则您没有指定 WHERE 语法,因此它实际上引用任何行。

如果结果大于 0,那么如果您认为它不会影响任何行,那么您就错了。它可能不会影响您认为应该影响的行,但这是另一个问题。

另外,echo 您的 sql 语句,这样您就可以准确地看到它在做什么。

See what the result from mysql_affected_rows() is:

if ( ! $result53543534 = mysql_query( "UPDATE users SET credit=credit+1 WHERE email= '{$battle_get['username']}'") ) {
    die( mysql_error() );
} else {
    echo "Number of rows affected: " . mysql_affected_rows() . "<br>";
}

I may not have the syntax completely right but I hope you get the idea. If the result is 0, you're not specifying the WHERE syntax so that it actually refers to any row(s).

If the result is greater than 0, then you're mistaken if you think it's not affecting any rows. It may not be affecting the rows you think it should, but that's another issue.

Also, echo your sql statement so you can actually see exactly what it's doing.

∞觅青森が 2024-11-18 01:21:34

尝试测试

$email = $battle_get['username'];
UPDATE users SET credit=credit+1 WHERE email= '$email'

Try testing

$email = $battle_get['username'];
UPDATE users SET credit=credit+1 WHERE email= '$email'
贪了杯 2024-11-18 01:21:34

您忘记将查询提交到数据库,请尝试事务

mysql_query("START TRANSACTION");
mysql_query("UPDATE users SET credit=credit+1 WHERE email= '{$battle_get['username']}'");
mysql_query("COMMIT");

you forgot about committing the query to database, try transaction

mysql_query("START TRANSACTION");
mysql_query("UPDATE users SET credit=credit+1 WHERE email= '{$battle_get['username']}'");
mysql_query("COMMIT");
一袭水袖舞倾城 2024-11-18 01:21:34

我建议将代码更改为如下,它将允许您检查 sql 查询。尝试测试 sql 查询以查看它是否完全运行。您可能还想在 mysql 控制台上运行 DESCRIBE users 来查看获得的信息类型。

$sql = "UPDATE users SET credit=credit+1 WHERE email= '{$battle_get['username']}'"
echo $sql;
if ( ! $result53543534 = mysql_query($sql) ) {
    die( mysql_error() );
} else {
    echo "Number of rows affected: " . mysql_affected_rows() . "<br>";
}

I would suggest changing the code to as follows, it will allow you to examine the sql query. Try testing the sql query to see if it runs at all. You may also want to run DESCRIBE users on your mysql console to see what sort of information you get.

$sql = "UPDATE users SET credit=credit+1 WHERE email= '{$battle_get['username']}'"
echo $sql;
if ( ! $result53543534 = mysql_query($sql) ) {
    die( mysql_error() );
} else {
    echo "Number of rows affected: " . mysql_affected_rows() . "<br>";
}
っ〆星空下的拥抱 2024-11-18 01:21:34

向您为此使用的连接中的用户授予 UPDATE 权限。仅仅因为用户能够 SELECT 和 INSERT,并不意味着他们也可以自动 UPDATE,您需要显式授予他们 UPDATE 权限。并且 mysql_error() 也不会显示任何错误,因为您的 SQL 语句是正确的,因此不会显示错误。

Grant UPDATE permission to the user in the connection you're using for this. Just because the user is able to SELECT and INSERT, does not mean they can automatically UPDATE as well, you need to explicitly grant them the permission to UPDATE. And also mysql_error() will not show any error because your SQL statement is correct, hence no error shown.

怪我太投入 2024-11-18 01:21:34

我也遇到了同样的事情,我首先做的是在 MySQL Workbench 上重现它,然后使用那里的 SQL 语句,我发现(不知道为什么)它可以在 WHERE 子句后添加括号:

UPDATE users SET credit = credit + 1 WHERE (`email`= '{$battle_get['username']}')

Happen to me the same thing, what I did first was to reproduce it on MySQL Workbench then use the SQL sentences from there, I found out (not sure why) it works adding parenthesis after the WHERE clause:

UPDATE users SET credit = credit + 1 WHERE (`email`= '{$battle_get['username']}')
老娘不死你永远是小三 2024-11-18 01:21:34

请检查您提到的姓名=电子邮件
所有输入字段中都有 name=password 属性,如果输入的话,还会在提交中提到 name=submit 。

Please check you mention name=email
And name=password attributes in all input field and also mention in name=submit in submit if it's input.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文