MySQLi预处理语句未执行 [英] MySQLi Prepared Statement not executing

查看:50
本文介绍了MySQLi预处理语句未执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码运行无任何错误,但实际上并未删除任何内容:

The following code runs without any errors but doesn't actually delete anything:

      $update = $mysqli->prepare('DELETE FROM table WHERE RetailerID = ? AND Amount = ? AND FXRate = ?');
      $update->bind_param('iii', $rID, $base_value, $fx_rate);
      $update->execute();
      $update->close();

我在同一文件中有许多mysqli准备好的语句,可以很好地执行,但这是唯一不修改表的语句.没有错误或未显示,但该行也未从表中删除.我已验证$ rID,$ base_value和$ fx_rate是正确的值,并且表中肯定存在与这些值匹配的行.

I have numerous mysqli prepared statments in this same file that execute fine, but this one is the only one that doesn't modify the table. No errors or shown, but the row isn't deleted from the table either. I have verified that $rID, $base_value, and $fx_rate are the correct values, and a row is DEFINITELY present in table that matches those values.

此语句与其他语句之间的唯一区别是参数以及它是DELETE而不是SELECT或UPDATE的事实.我也尝试使用相同的WHERE参数进行SELECT或UPDATE而不是DELETE,但是没有运气.问题似乎在于它找不到适合WHERE参数的行,但是就像我说的那样,该行肯定在那里.

The only difference between this statement and the others are the parameters and the fact that it's DELETE instead of SELECT or UPDATE. I also tried doing a SELECT or UPDATE instead of DELETE using the same WHERE parameters, but no luck. The issue seems to be that it's not finding a row that fits the WHERE parameters, but like I said, the row is definitely there.

有什么想法吗?

推荐答案

金额是整数还是双精度数?您正在转换为整数('iii'),但我想它将是0.34美元或类似金额.尝试使用"idi"代替.

Is amount an integer or a double? You're converting to integer ('iii'), but I presume it'll be $0.34 or similar. Try 'idi' instead.

同样适用于费率-也是整数还是双精度?

same applies for rate - is that an integer or double too?

这篇关于MySQLi预处理语句未执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆