尝试从php表单更新db值但不反映任何结果

时间:2016-07-06 09:37:50

标签: php

这里是我的php程序:

public function updateUser($id,$name,$lname,$username,$password,$gender,$email,$mobile,$address) {
  printF($id);
  $update = ("UPDATE oops SET firstname = '$name',lastname = '$lname', username= '$username',password='$password',email = '$email', gender = '$gender', mobile = '$mobile' , address = '$address' WHERE uid = '$id'");
  printF($update);
  $result = mysql_query($update);

  if ($result) {
    return true;
  } else {
    return false;
  }
}

1 个答案:

答案 0 :(得分:0)

尝试从$update变量和DO NOT使用mysql_*功能中删除()括号,使用mysqli_*代替mysql_*

public function updateUser($id,$name,$lname,$username,$password,$gender,$email,$mobile,$address) {
  printF($id);
  $update = "UPDATE oops SET firstname = '$name',lastname = '$lname', username= '$username',password='$password',email = '$email', gender = '$gender', mobile = '$mobile' , address = '$address' WHERE uid = '$id'";

  printF($update);
  $result = mysqli_query($update);

  if ($result) {
    return true;
  } else {
    return false;
  }
}