我正在尝试发出一个mysqli_multi_query,其中我的查询名为$ query& $ QUERY2。查询1是来自查询2的单独表。这是代码语法的示例:
$query1 = "INSERT INTO invoices (`id`,`c`) VALUES (NULL, '$client_id')";
$query2 = "UPDATE `customers` SET `a` = `$a`,`b` = `$b` WHERE `customers.id` = $client_id";
invoices.client_id与customers.id相同,我只想更新与发票client_id匹配的customers.id。
由于某些奇怪的原因,我的发票中的所有内容都已更新,但不会更新到我的客户中。我的语法是否正确?
答案 0 :(得分:0)
您的代码:
$query2 = "UPDATE customers SET alarmcode = $alarmcode, garagecode = $garagecode, gatecode = $gatecode, liason = $liason, lphone = $lphone WHERE customers.id = '$client_id'";
表清晰度:
所以问题是在sql语句中没有正确封装字符串。
更正后的陈述是:
$query2 = "UPDATE customers SET alarmcode = '$alarmcode', garagecode = '$garagecode', gatecode = '$gatecode', liason = '$liason', lphone = '$lphone' WHERE id = $client_id";