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";

Recommended Answers

All 2 Replies

What's the data type for your student_code field?

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.