我的代码出了什么问题,因为插入工作正常,但更新无效。我已经从phpmyadmin复制了updaet的查询,并将静态值更改为变量
<?php
if (isset($_POST['submitContactInfo'])) {
$socityId = $_SESSION['socityid'];
$city = $_POST['city'];
$pin = $_POST['pin'];
$state = $_POST['state'];
$telephone = $_POST['telephone'];
$mobile = $_POST['mobile'];
$email = $_POST['email'];
$address = $_POST['address'];
$sql = "INSERT INTO `_abc1`.`profile` (SOCIETY_ID,ADDR,CITY,PIN,STATE,TEL,MOBILE,EMAIL) VALUES ('$socityId','$address','$city','$pin','$state','$telephone','$mobile','$email');";
$sql = "UPDATE `_abc1`.`profile` SET `ADDR` = '$address', `CITY` = '$city', `PIN` = '$pin', `STATE` = '$state', `TEL` = '$telephone', `MOBILE` = '$mobile', `EMAIL` = '$email' WHERE `society_profile`.`SOCITY_ID` = '$socityId'; ";
$res = mysql_query($sql);
}
?>
答案 0 :(得分:1)
您的更新中有拼写错误。在第一个查询中,您有SOCITY_ID,它是SOCIETY_ID
试
$sql = "UPDATE `_abc1`.`profile` SET `ADDR` = '$address', `CITY` = '$city', `PIN` = '$pin', `STATE` = '$state', `TEL` = '$telephone', `MOBILE` = '$mobile', `EMAIL` = '$email' WHERE `SOCIETY_ID` = '$socityId'; ";
此外,如上所述,您应该使用mysqli_query而不是这些旧的弃用函数。
答案 1 :(得分:0)
答案 2 :(得分:0)
试试这个..
$sql = "UPDATE '_abc1'.'profile' SET 'ADDR' = '".$address."', 'CITY' = '".$city."', 'PIN' = '".$pin."', 'STATE' = '".$state."', 'TEL' = '".$telephone."', 'MOBILE' = '".$mobile."', 'EMAIL' = '".$email."' WHERE 'society_profile'.'SOCITY_ID' = '".$socityId."'; ";