无法将数据推送到mysql

时间:2017-11-01 03:59:50

标签: mysql database

我似乎无法将数据从我的表单推送到数据库,我检查了error_log并且没有错误。请检查下面的代码,谢谢!

<?php 
   $con=mysqli_connect("localhost","admineventus","J7!ren;3") or Die ("Cannot connect");
    mysqli_select_db($con,"eventus");


if(isset($_POST['submitpublish']))
   {
  mysqli_query($con,"insert into events values('$_POST[Category]','$_POST[Name]','$_POST[Location]','$_POST[Sdate]','$_POST[Edate]','$_POST[Etime]','$_POST[Fee]','$_POST[Free]','$_POST[About]')");
     }
                 ?>

1 个答案:

答案 0 :(得分:0)

试试这个

if(isset($_POST['submitpublish']))
 {
 $sql = "INSERT INTO events (col1, col1, .. , colx)
VALUES ('".$_POST["Category"]."','".$_POST["Name"]."','".$_POST["Location"]."','".$_POST["Sdate"]."','".$_POST["Sdate"]."','".$_POST["Edate"]."','".$_POST["Etime"]."','".$_POST["Fee"]."','".$_POST["Free"]."','".$_POST["About"]."')";

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

确保您的代码输入IF声明