mysqli\u查询不向表中插入数据

gg58donl  于 2021-06-19  发布在  Mysql
关注(0)|答案(2)|浏览(297)

有人能找到问题吗?它不会给出任何错误,但是数据库中不会出现新行,我也不知道问题出在哪里。

if (isset( $_REQUEST['signupnbtn'] ) ) {
    $age = mysqli_real_escape_string($con,$_REQUEST['ageinput']);
    $discord = mysqli_real_escape_string($con,$_REQUEST['discordinput']);
    $email = mysqli_real_escape_string($con,$_REQUEST['emailinput']);
    $tmp = mysqli_real_escape_string($con,$_REQUEST['tmpinput']);
    $steam = mysqli_real_escape_string($con,$_REQUEST['steaminput']);
    $datum = date("d-m-Y");
    $errorcode = 0;

    $q = "INSERT INTO `admissions` (age, discord, email, tmp, steam, datum)
    VALUES ('$age', '$discord', '$email', '$tmp', '$steam', '$datum')";
    $query2 = "SELECT email FROM `admissions` WHERE email='$email'";
    $sql = mysqli_query($con,$query2);
    $countrows = mysqli_num_rows($sql);
    if($countrows >= 1){
      $errorcode = 1;
    }else {
      $result = mysqli_query($con,$q);
    }
      if ($result) {
        $errorcode = 4;
      }

  }
i1icjdpr

i1icjdpr1#

问题解决后,日期应为“y-m-d”格式,而不是“d-m-y”,如下所示:

if (isset( $_REQUEST['signupnbtn'] ) ) {
    $age = mysqli_real_escape_string($con,$_REQUEST['ageinput']);
    $discord = mysqli_real_escape_string($con,$_REQUEST['discordinput']);
    $email = mysqli_real_escape_string($con,$_REQUEST['emailinput']);
    $tmp = mysqli_real_escape_string($con,$_REQUEST['tmpinput']);
    $steam = mysqli_real_escape_string($con,$_REQUEST['steaminput']);
    $datum = date("Y-m-d");
    $errorcode = 0;
    $q = "INSERT INTO `admissions` (age, discord, email, tmp, steam, datum)
    VALUES ('$age', '$discord', '$email', '$tmp', '$steam', '$datum')";
    $query2 = "SELECT email FROM `admissions` WHERE email='$email'";
    $sql = mysqli_query($con,$query2);
    $countrows = mysqli_num_rows($sql);
    if($countrows >= 1){
      $errorcode = 1;
    }else {
      $result = mysqli_query($con,$q);
    }
      if ($result) {
        $errorcode = 4;
      }
  }
mzsu5hc0

mzsu5hc02#

$q = "INSERT INTO admissions (age, discord, email, tmp, steam, datum) VALUES ('$age', '$discord', '$email', '$tmp', '$steam', '$datum')";

相关问题