I'm trying to query from two tables but whenever i run my php script i get this error, any help would be highly appreciated

Database query failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'student_code = '01' AND firstname = 'kabula' LIMIT 1' at line 1

$query = "SELECT student.student_code, student.firstname, student.middlename, student.lastname, student.gender, school.school_name ";
            $query .= "FROM student INNER JOIN school ";
            $query .= "ON student.school_code=school.school_code";
            $query .= "WHERE student_code = '{$student_code}' ";
            $query .= "AND firstname = '{$firstname}' ";
            $query .= "LIMIT 1";
2 Years
Discussion Span
Last Post by punji

thanks guys i have found the solution, i was suppose to leave space between the double quotes and keyword FROM, space between double quotes and keyword ON, space between double quotes and keyword WHERE and so on. the data type for student_code is varchar.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.