电子邮件导致mysqli查询失败

时间:2013-12-30 16:21:55

标签: php mysqli

尝试运行一个简单的查询,将一些数据插入到用户表中,但是电子邮件(@符号更具体)导致查询失败。这是代码:

$query = "insert into user (username, password, email) value (?,?,?)";
if ($stmt = $mysqli->prepare($query)) {
  $this->email = $mysqli->real_escape_string($this->email);
  $stmt->bind_param('sss', $this->screenName, $this->password, $this->email);
  $stmt->execute();
  if ($mysqli->affected_rows != -1) {
    $this->uid = $stmt->insert_id;
    $response = array("status" => "success");
  } else {
    $response = array("error" => "db error while inserting");   //db error
  }
} else {
  $response = array("error" => "db error");   //db error
}

它只是在插入时打印db错误,理想情况下它应该让我“成功” 注意:这只是一个代码段。假设数据库连接都正常工作。

0 个答案:

没有答案