PHP Sql查询问题

时间:2015-08-21 13:29:14

标签: php mysql mysqli

有人可以告诉我为什么我会收到此错误消息吗?

  

错误消息:您的SQL语法中有错误;查看与您的MySQL服务器版本相对应的手册,以获得在''附近使用的正确语法。在第1行

<?php
    /*make database connection*/
            $conn = new mysqli($servername, $username, $password, $dbname);

            /*get all values*/
            $event_name = isset($STORE_EVENT['event_name'])?mysqli_real_escape_string($conn,$STORE_EVENT['event_name']):"";
            $event_desc=isset($STORE_EVENT['event_desc'])?mysqli_real_escape_string($conn,$STORE_EVENT['event_desc']):"";
            $event_img=isset($STORE_EVENT['event_img'])?mysqli_real_escape_string($conn,$STORE_EVENT['event_img']):"";
            $event_date=isset($STORE_EVENT['event_date'])? mysqli_real_escape_string($conn,$STORE_EVENT['event_date']):"";
            $event_signup_date=isset($STORE_EVENT['event_signup_date'])?mysqli_real_escape_string($conn,$STORE_EVENT['event_signup_date']):"";
            $event_entry=isset($STORE_EVENT['event_entry'])?mysqli_real_escape_string($conn,$STORE_EVENT['event_entry']):"";
            $event_start=isset($STORE_EVENT['event_start'])?mysqli_real_escape_string($conn,$STORE_EVENT['event_start']):"";
            $event_fee=isset($STORE_EVENT['event_fee'])?mysqli_real_escape_string($conn,$STORE_EVENT['event_fee']):"";
            $event_stack=isset($STORE_EVENT['event_stack'])?mysqli_real_escape_string($conn,$STORE_EVENT['event_stack']):"";
            $blinds=isset($STORE_EVENT['blinds'])?mysqli_real_escape_string($conn,$STORE_EVENT['blinds']):"";
            $event_struktur=isset($STORE_EVENT['event_struktur'])?mysqli_real_escape_string($conn,$STORE_EVENT['event_struktur']):"";
    $event_signup_date = date_german2mysql($event_signup_date);
    $event_date = date_german2mysql($event_date);

            $validations=1;


                $sql ="INSERT INTO wp_events(`event_name`,`event_desc`,`event_img`,`event_date`,`event_signup_date`,`event_entry`,`event_start`,`event_fee`,`event_stack`,`event_blinds`,`event_struktur`)VALUES('$event_name','$event_desc','$event_img','$event_date','$event_signup_date','$event_entry','$event_start','$event_fee','$event_stack','$blinds','$event_struktur'";


    if (!$conn->query($sql)) {
        printf("Errormessage: %s\n", $conn->error);
    }


    $thread_id = $conn->thread_id;
    $conn->kill($thread_id);
    $conn->close();
    }

?>

1 个答案:

答案 0 :(得分:1)

您在SQL查询结束时错过了结束)。试试这个:

$sql = "INSERT INTO wp_events (`event_name`,`event_desc`,`event_img`,`event_date`,`event_signup_date`,`event_entry`,`event_start`,`event_fee`,`event_stack`,`event_blinds`,`event_struktur`) VALUES ('$event_name','$event_desc','$event_img','$event_date','$event_signup_date','$event_entry','$event_start','$event_fee','$event_stack','$blinds','$event_struktur')";