php表单不向数据库发送数据

ltskdhd1  于 2021-06-20  发布在  Mysql
关注(0)|答案(1)|浏览(367)

有人能帮我,告诉我为什么我的php表单不发送数据到数据库。
类型是 emp_no(int11) , birth_date(date) , first_name(varchar14) , last_name(varchar16) , gender(enum('M','F') , hire_date(date) ```
// Checks to see if the save button was pressed and if so, then it should run the
query that inserts the data into the data fields specified.
if(isset($_POST['save'])) {

$sql = "INSERT INTO 'employees' ('emp_no', 'birth_date', 'first_name', 
'last_name', 'gender', 'hire_date')
VALUES ('".$_POST['emp_no']."', '".$_POST['birth_date']."', 
'".$_POST['first_name']."', '".$_POST['last_name']."',
'".$_POST['gender']."', '".$_POST['hire_date']."')";

$result = mysqli_query($conn, $sql);

}
此处代码:https://codepen.io/blackemr/pen/mjmgpq
nszi6y05

nszi6y051#

更改为:

$sql = "INSERT INTO employees (emp_no, birth_date, first_name, last_name, gender, hire_date) VALUES ...

也可以使用以下方法返回错误:

$result = mysqli_query($conn, $sql) or trigger_error(mysqli_error($conn));

相关问题