好的,所以这允许我创建项目并将它们添加到数据库中,但由于某种原因,它没有添加任何东西,我知道那里有一个错字或代码中的某些内容,但我可以&找不到我的生命。它已经绞尽脑汁一阵子了。
if(isset($_POST['project_name'])&&isset($_POST['project_lead'])&&isset($_POST['project_type'])&&isset($_POST['project_start'])&&isset($_POST['project_due'])&&isset($_POST['project_link'])&&isset($_POST['project_desc'])) {
$project_name = $_POST['project_name'];
$project_lead = $_POST['project_lead'];
$project_type = $_POST['project_type'];
$project_start = $_POST['project_start'];
$project_due = $_POST['project_due'];
$project_link = $_POST['project_link'];
$project_desc = $_POST['project_desc'];
$esc_project_link = mysql_real_escape_string($project_link);
$esc_project_desc = mysql_real_escape_string($project_desc);
if(!empty($project_lead)&&!empty($project_name)&&!empty($project_type)&&!empty($project_start)&&!empty($project_due)&&!empty($project_link)&&!empty($project_desc)) {
$insert_new_project = "INSERT INTO projects VALUES ('','$project_name','$project_lead','$project_type','$project_start','$project_due','$esc_project_link','$esc_project_desc')";
if($insert_success = mysql_query($insert_new_project)) {
header('Location: projects.php?new=true');
} else {
header('Location: projects.php?new=fail');
}
}
}
提前致谢!
答案 0 :(得分:0)
您应该声明插入数据的列:
$insert = "INSERT INTO table_name
(column1, column2, column3,...)
VALUES (value1, value2, value3,...)
WHERE value1 = 'yourvalue'";
这是w3schools.com的正确语法插入。
有关详细信息,请查看w3schools.com