Answers for "how to fix 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"

SQL
0

how to fix 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 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
Posted by: Guest on November-12-2021

Code answers related to "how to fix 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"

Code answers related to "SQL"

Browse Popular Code Answers by Language