【问题标题】:updating array response to mysql table更新对mysql表的数组响应
【发布时间】:2019-11-23 21:57:32
【问题描述】:

我有以下有效的查询。

$sql = "UPDATE tblDebits_Drafted SET RecordID = '123', ErrorDescription = 'test4' WHERE AccountID = '2222100000010717' AND DRC_TransactionID = '7'";  

我正在将值转换为来自两个不同数组的变量。 RecordID 和 ErrorDescription 来自响应数组,AccountID 和 DRC_Transaction 来自输入数组。

这些是变量,它们工作得很好:

$AccountID = $data['AccountID'];echo '<br>';
                $EffectiveDate = $data['EffectiveDate'];echo '<br>';
                $DayOfMonth = $data['DayOfMonth'];echo '<br>';
                $DebitType = $data['DebitType'];echo '<br>';
                $DebitAmount = $data['DebitAmount'];echo '<br>';
                $Memo = $data['Memo'];echo '<br>';
                $DRC_TransactionID =$data['DRC_TransactionID'];echo '<br>';

                $RecordID = $AmpResponse['AddDebitOrFeeResult']['RecordID'];echo '<br>';
                $ErrorDescription = $AmpResponse['AddDebitOrFeeResult']['ErrorDescription'];

这是我迄今为止的查询,但设置不正确。 WHERE 和 AND 关键字无效。

$sql = "UPDATE tblDebits_Drafted SET RecordID = '".$RecordID."', ErrorDescription = '".$ErrorDescription."' WHERE AccountID = '".$AccountID."' AND DRC_TransactionID = '".$DRC_TransactionID."'";

不知道怎么写才能正常运行... 任何帮助,将不胜感激。谢谢。

【问题讨论】:

  • 您是否收到错误,当是时,究竟是哪一个?
  • 此时 sql 什么也没返回。
  • echo sql请使用prepared statements,其次使用错误管理查看是否有错误发生

标签: mysql sql syntax associative-array


【解决方案1】:

最终的解决方案如下:

$sql1 = "UPDATE tblDebits_Drafted SET RecordID = '$RecordID', ErrorDescription = '$ErrorDescription' WHERE AccountID = '$AccountID' AND DRC_TransactionID = '$DRC_TransactionID'";

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-06-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-18
    • 2021-12-27
    相关资源
    最近更新 更多