在数据库表中插入变量时出现问题


Issues inserting variables in my database table?

<?php
     $hostname="It is in correctly";
     $username="It is in correctly";
     $password="It is in correctly";
     $dbname="It is in correctly";
      $db_conx = mysqli_connect($hostname, $username, $password) OR DIE ("Unable to
      connect to database! Please try again later.");
      if(mysqli_connect_errno()){
      echo mysqli_connect_error();
      exit();
      }
  $select = mysqli_select_db($db_conx,$dbname);
  $firstname= $_POST["first_name"];
  $lastname= $_POST["last_name"];
  $email= $_POST["email"];
  $password= $_POST["password"];
  $gender= $_POST["gender"];
  mysqli_query($db_conx,"INSERT INTO users (firstname, lastname, email, password, gender)
 VALUES ($firstname, $lastname, $email, $password, $gender)");
 mysqli_close($db_conx);
?>

       <form method="POST" name="signup" action="php/signup_script.php">
<label for="first    name"></label>
<input id="first name" name="first_name" placeholder="First Name" type="text" /> 
<label for="last_name"></label>
<input id="last name" name="last_name" placeholder="Last Name" type="text" />
<br><br><label for="email">
</label><input id="email" name="email" placeholder="Email" type="email" />
    <label for="password"></label><input id="password" name="password" placeholder="Create Password" type="password" />
    <label for="male"><strong>Male</strong></label>
 <input id="male" value="Male" name="gender" type="radio" />
 <label for="female"><strong>Female</strong>
</la... <input id="female" value="Female" name="gender" type="radio" />
    <label for="submit">"I Agree To Terms And Conditions"</label>
 <input id="submit" value="Submit" type="submit" name="submit"/>
    </form> 

您忘记将insert查询中的php变量用单引号括起来,请更正。

mysqli_query($db_conx,"INSERT INTO users (firstname, lastname, email, password, gender)
 VALUES ('$firstname', '$lastname', '$email', '$password', '$gender')");