MDanz Posted January 8, 2011 Share Posted January 8, 2011 Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\xampp\test.php on line 58 line 58 is the where the while loop starts.. what have i done wrong? $query2 = mysql_query("SELECT student.SID, course.CID FROM student, course WHERE student.SID = `student-course.SID` AND course.CID = `student-course.CID` AND GRADE BETWEEN $beginning AND $grade",$this->connect); while($row = mysql_fetch_assoc($query2)) { $sid = $row['student.SID']; $cid = $row['course.CID']; echo "$sid-$cid"; } Quote Link to comment https://forums.phpfreaks.com/topic/223746-warning-mysql_fetch_assoc-expects-parameter-1-to-be-resource/ Share on other sites More sharing options...
trq Posted January 8, 2011 Share Posted January 8, 2011 You haven't checked the query succeeds or contains any records before using it. Quote Link to comment https://forums.phpfreaks.com/topic/223746-warning-mysql_fetch_assoc-expects-parameter-1-to-be-resource/#findComment-1156557 Share on other sites More sharing options...
MDanz Posted January 8, 2011 Author Share Posted January 8, 2011 ok after some changing up i get this message Notice: Undefined index: student.SID in C:\xampp\test.php on line 62 Notice: Undefined index: course.CID in C:\xampp\test.php on line 63 $sid = $row['student.SID']; $cid = $row['course.CID']; here is the query $query2 = mysql_query("SELECT student.SID, course.CID FROM student, course, `student-course` WHERE student.SID = `student-course`.SID AND course.CID = `student-course`.CID AND GRADE BETWEEN $beginning AND $grade",$this->connect)or die(mysql_error()); this is a relational database...can you see whats wrong? Quote Link to comment https://forums.phpfreaks.com/topic/223746-warning-mysql_fetch_assoc-expects-parameter-1-to-be-resource/#findComment-1156563 Share on other sites More sharing options...
DavidAM Posted January 8, 2011 Share Posted January 8, 2011 The table qualifier will not be in the array key. Try this: $sid = $row['SID']; $cid = $row['CID']; Quote Link to comment https://forums.phpfreaks.com/topic/223746-warning-mysql_fetch_assoc-expects-parameter-1-to-be-resource/#findComment-1156566 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.