gpt4 book ai didi

php - MySQL 更新查询不会工作

转载 作者:太空宇宙 更新时间:2023-11-03 11:14:39 24 4
gpt4 key购买 nike

这个脚本有什么问题?我无法弄清楚这个问题!

function editAccount() {
$id = $_POST['id'];
$rep = $_POST['rep'];
$lastchange = date('mdY');
$account = $_POST['account'];
$areacode = $_POST['areacode'];
$number = $_POST['number'];
$address1 = $_POST['address1'];
$address2 = $_POST['address2'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$country = $_POST['country'];
$fax = $_POST['fax'];
$descmaker1 = $_POST['descmaker1'];
$descmaker2 = $_POST['descmaker2'];
$title = $_POST['title'];
$email = $_POST['email'];
$cvendor = $_POST['cvendor'];
$cequipment = $_POST['cequipment'];
$leaseexp1 = $_POST['leaseexp1'];
$leaseexp2 = $_POST['leaseexp2'];
$leaseexp3 = $_POST['leaseexp3'];
$leaseexp4 = $_POST['leaseexp4'];
$leaseexp5 = $_POST['leaseexp5'];
$leaseexp6 = $_POST['leaseexp6'];
$volume = $_POST['volume'];
$notes = $_POST['notes'];

mysql_db_query("UPDATE accounts
SET (lastchange = '$lastchange',
account = '$account',
areacode = '$areacode',
number = '$number',
address1 = '$address1',
address2 = '$address2',
city = '$city',
state = '$state',
zip = '$zip',
fax = '$fax',
descmaker1 = '$descmaker1',
descmaker2 = '$descmaker2',
title = '$title',
email = '$email',
cvendor = '$cvendor',
cequipment = '$cequipment',
leaseexp1 = '$leaseexp1',
leaseexp2 = '$leaseexp2',
leaseexp3 = '$leaseexp3',
leaseexp4 = '$leaseexp4',
leaseexp5 = '$leaseexp5',
leaseexp6 = '$leaseexp6',
volume = '$volume',
notes = '$notes')
WHERE id = $id");
}

错误:

警告:第 83 行/home/content/53/7311353/html/cca/accounts/include/processAct.php 中 mysql_db_query() 的参数计数错误

行是:WHERE id=$id");

最佳答案

UPDATE 命令中,去掉括号。就是这样。

另外,请注意 SQL Injection .

更新

最终代码应该是这样的:

function editAccount() {
$id = $_POST['id'];
$rep = $_POST['rep'];
$lastchange = date('mdY');
$account = $_POST['account'];
$areacode = $_POST['areacode'];
$number = $_POST['number'];
$address1 = $_POST['address1'];
$address2 = $_POST['address2'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$country = $_POST['country'];
$fax = $_POST['fax'];
$descmaker1 = $_POST['descmaker1'];
$descmaker2 = $_POST['descmaker2'];
$title = $_POST['title'];
$email = $_POST['email'];
$cvendor = $_POST['cvendor'];
$cequipment = $_POST['cequipment'];
$leaseexp1 = $_POST['leaseexp1'];
$leaseexp2 = $_POST['leaseexp2'];
$leaseexp3 = $_POST['leaseexp3'];
$leaseexp4 = $_POST['leaseexp4'];
$leaseexp5 = $_POST['leaseexp5'];
$leaseexp6 = $_POST['leaseexp6'];
$volume = $_POST['volume'];
$notes = $_POST['notes'];

mysql_query("UPDATE accounts
SET lastchange = '$lastchange',
account = '$account',
areacode = '$areacode',
number = '$number',
address1 = '$address1',
address2 = '$address2',
city = '$city',
state = '$state',
zip = '$zip',
fax = '$fax',
descmaker1 = '$descmaker1',
descmaker2 = '$descmaker2',
title = '$title',
email = '$email',
cvendor = '$cvendor',
cequipment = '$cequipment',
leaseexp1 = '$leaseexp1',
leaseexp2 = '$leaseexp2',
leaseexp3 = '$leaseexp3',
leaseexp4 = '$leaseexp4',
leaseexp5 = '$leaseexp5',
leaseexp6 = '$leaseexp6',
volume = '$volume',
notes = '$notes'
WHERE id = $id");
}

关于php - MySQL 更新查询不会工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5986680/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com