I'm trying to write an INNER JOIN
query. I wanted to get rows/information that are in two different tables. Here's what I'm trying:
Table Names are: Students and main_table
$sql =mysql_query ("SELECT main_table.maric_no, main_table.academic_session, main_table.semester,
main_table.course_name, main_table.total, students.first_name, students.last_name,
students.other_name, students.level
FROM main_table INNER JOIN students ON
main_table.matric_no = students.matric_no
WHERE main_table.matric = mysql_real_escape_string($_POST[matric_no]'");
$number_cols = mysql_num_fields($sql);
Here's the error message:
ERROR: mysql_num_fields() expects parameter 1 to be resource, boolean given in c:\filepath on line Number..
Where could the problem be coming from?
or die( mysql_error() )
to the end of the query to find out if you have errors. – JJJ Feb 6 '12 at 16:47