📜  如何修复您的 SQL 语法有错误;查看与您的 MariaDB 服务器版本相对应的手册,了解在第 1 行的 '' 附近使用的正确语法 - SQL 代码示例

📅  最后修改于: 2022-03-11 15:04:54.203000             🧑  作者: Mango

代码示例1
/* You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1

You get the above error when you are concatenating a NULL variable in your SQL Statement 

I fixed mine by adding an if statement to check if the possible variable is NULL*/

if($admin_data['hotel_id'] != NULL){
        $sql .= " AND hotel_id =".$admin_data['hotel_id'];
    }
    
-- But it is STRONGLY advised to avoid this style of coding since it is vulnerable to SQL Injecton Attacks