无法使用php

时间:2016-01-17 15:08:03

标签: php mysql

这个php代码写在我文件的末尾

 <?php

if(isset($_POST['submit']))
{
  $Jobtitle = $_POST['jobtitle'];
  $Firstname = $_POST['firstname'];
  $Lastname = $_POST['lastname'];
  $Name=$Firstname+$Lastname;
  $Sin = $_POST['sin'];
  $Phone = $_POST['phone'];
  $Email = $_POST['email'];
  $Address = $_POST['address'];
  $Postal = $_POST['postal'];
  $State = $_POST['state'];
  $Country = $_POST['country'];
  $Skill = $_POST['skill'];
  $Owntransport = $_POST['owntransport'];
  $ADate = $_POST['a-date'];
  $Workpermit = $_POST['workpermit'];
  $Daysavailable = $_POST['days-available'];
  $Strength = $_POST['strength'];
  $eFirstname = $_POST['efirstname'];
  $eLastname = $_POST['elastname'];
  $eName=$eFirstname+$eLastname;
  $ePhone = $_POST['ephone'];
  $query=" INSERT INTO `general`(`jobtitle`, `name`, `sin`, `pno`, `email`, `address`, `doc`, `skills`, `transport`, `avadate`, `authorize`, `days`, `strength`, `ename`, `ephone`) VALUES ('{$Jobtitle}','{$Name}','{$Sin}','{$Phone}','{$Email}','{$Address}','{$Postal}','{$State}','{$Country}','{$Skill}','{$Owntransport}','{$ADate}','{$Workpermit}','{$Daysavailable}','{$Strength}','{$eName}','{$ePhone}')";
 // $query = "INSERT INTO info (name,password,gender,hobby,phone no,dob,message) VALUES ('{$Name}','{$Password}','{$Gender}','{$Hobby}','{$Phone}','{$Dob}','{$Message}')";
  $result = mysql_query($query);
  if($result)
  {
    echo "data entered";
  }
  unset($_POST);
}
else{
  echo "error in entering data";
}

&GT;

这是按钮标签

<button type="button" class="btn btn-primary"name="submit"value="submit" id="submit">Submit</button>

这是表格标签

<form method="post" id="contactform" action="#" role="form">

连接.php文件给我连接到数据库但我无法将数据存储在数据库中它给我的错误 未输入数据

1 个答案:

答案 0 :(得分:1)

问题是,您正在使用15 columns并尝试更新17 values

我认为您错过了statepostal列。

旁注:

还有两个问题:

  1. 使用mysql_*扩展名已弃用,但在PHP 7中不可用。
  2. 您的代码已打开SQL注入。
  3. <强>建议:

    使用mysqli_*PDO作为第1点。

    要进行调试,请始终在代码中使用活跃的PHP error_reprting