这个PHP代码有什么错误?

时间:2017-09-07 04:43:02

标签: php mysql sql database phpmyadmin

<?php   
    include("conn.php");
    if(isset($_POST['save'])){

        $title=$_POST['title'];
        $genre=$_POST['genre'];
        $year=$_POST['year'];

        $sql = "INSERT INTO `add`(`title`, `genre`, `year`) VALUES ('$title','$genre','$year')" ;
            $query = mysql_query($sql);
        if (empty ($_POST["title"] || ["genre"] || ["year"])){
            echo "You did not fill out the required fields.";
        }
        else ($query){
            echo "Successfully Inserted . <a href = 'index.php'> Ok </a>";
        }

    }


?>

每次运行代码时,都会出现错误:

  

“解析错误:语法错误,C:\ xampp \ htdocs \ Practice中的意外'{'   第24行“PHOBIAmming Skills \ sample1 \ add.php”

1 个答案:

答案 0 :(得分:1)

您已将条件添加到else

else ($query){

根据您的逻辑将其删除或制作elseif