PHP error debug
Error: mysql_num_rows(): supplied argument is not a valid MySQL result resource
Error type/ Nr.: Warning - 2
File: /data/www/manager/includes/document.parser.class.inc.php(797) : eval()'d code
Line: 58
Here's the code:
<?php
/*******************
parameters
$details==0 if the person wants just the summary
$details==1 if the person wants to see the course names and all other details for the particular person
$year=year u want for the Fall semester so that it will calculate accordingly
$sem=Fall|Spring|Summer
********************/
$sem = $_POST['selsemester'];
$year = $_POST['selyear'];
$faculty = $_POST['faculty'];
$details = $_POST['detail'];
//print_r($_POST);
if($sem=='Fall')
{
$year1=$year;
$year2=$year+1;
}
if(($sem=='Spring')||($sem=='Summer'))
{
$year1=$year-1;
$year2=$year;
}
echo "<br><strong>".$sem." ".$year1." - ".$year2."</strong><br><br>";
if($details==0)
{
$modx->runSnippet('DBConnect');
if($faculty=='adjunct')
{
$querypeople="select id,concat(people.lname,', ',people.fname) fullname ,people.g,people.designation from people where people.designation IN ('Adjunct Faculty') ORDER BY people.lname";
}
else
{
$querypeople="select id,concat(people.lname,', ',people.fname) fullname ,people.g,people.designation from people where people.designation IN ('Instructional Faculty','Administrative Faculty','Professional Faculty','Research Faculty','Faculty') ORDER BY people.lname";
}
$resultpeople=mysql_query($querypeople);
$numpeople=mysql_num_rows($resultpeople);
echo "<table border=1>";
echo "<tr><td><b>Faculty Lastname, firstname</b></td><td><b>G#</b></td><td><b>Fall FTE</b></td><td><b>Spring FTE</b></td><td><b>Total AY</b></td><td><b>Summer FTE</b></td><td><b>Total Full AY</b></td></tr>";
if($numpeople==0)
{
}
else
{
while($rowpeople=mysql_fetch_array($resultpeople))
{
echo "<tr><td>".$rowpeople['fullname']."</td><td>".$rowpeople['g']."</td>";
$querycredits="select sum(credit_hrs) as fallfte from courses_instances where year=".$year1." and semester='Fall' and person_id=".$rowpeople['id']."";
$total1=0;
$total2=0;
$resultcredits=mysql_query($querycredits);
$numcredits=mysql_num_rows($resultcredits);
if($numcredits==0)
{
echo "<td>0</td>";
$total1=$total1+0;
}
else
{
while($rowcredits=mysql_fetch_array($resultcredits))
{
echo "<td>".$rowcredits['fallfte']."</td>";
$cre=$rowcredits['fallfte'];
$total1=$total1+$cre;
}
}
$querycreditsspring="select sum(credit_hrs) as springfte from courses_instances where year=".$year2." and semester='Spring' and person_id=".$rowpeople['id']."";
$resultcreditsspring=mysql_query($querycreditsspring);
$numcreditsspring=mysql_num_rows($resultcreditsspring);
if($numcreditsspring==0)
{
echo "<td>0</td>";
$total1=$total1+0;
}
else
{
while($rowcreditsspring=mysql_fetch_array($resultcreditsspring))
{
echo "<td>".$rowcreditsspring['springfte']."</td>";
$cre1=$rowcredits['springfte'];
$total1=$total1+$cre1;
}
}
echo "<td>".$total1."</td>";
$querycreditssummer="select sum(credit_hrs) as summerfte from courses_instances where year=".$year2." and semester Like 'Summer%' and person_id=".$rowpeople['id']."";
$resultcreditssummer=mysql_query($querycreditssummer);
$numcreditssummer=mysql_num_rows($resultcreditssummer);
if($numcreditssummer==0)
{
echo "<td>0</td>";
$total2=$total2+0;
}
else
{
while($rowcreditssummer=mysql_fetch_array($resultcreditssummer))
{
echo "<td>".$rowcreditssummer['summerfte']."</td>";
$cre2=$rowcredits['summerfte'];
$total2=$total2+$cre2;
}
}
$ftotal=$total1+$total2;
echo "<td>".$ftotal."</td></tr>";
}
}
echo "</table>";
$modx->runSnippet('DBdisconnect');
}
else if($details==1)
{
$modx->runSnippet('DBConnect');
if($faculty=='adjunct')
{
$querypeople="select id,concat(people.lname,', ',people.fname) fullname ,people.g,people.designation from people where people.designation IN ('Adjunct Faculty') ORDER BY people.lname";
}
else
{
$querypeople="select id,concat(people.lname,', ',people.fname) fullname ,people.g,people.designation from people where people.designation IN ('Instructional Faculty','Administrative Faculty','Professional Faculty','Research Faculty','Faculty') ORDER BY people.lname";
}
$resultpeople=mysql_query($querypeople);
$numpeople=mysql_num_rows($resultpeople);
if($numpeople==0)
{
}
else
{
while($rowpeople=mysql_fetch_array($resultpeople))
{
echo "<p><b>".$rowpeople['fullname'].", ".$rowpeople['g']."</b></p>";
echo "<table border=1>";
echo "<tr><td>Semester</td><td>Course</td><td>Title</td><td>Credits</td><td>Enrollment</td><td>Course Release</td><td>Notes</td></tr>";
$querycredits="select courses_instances.semester as Semester,courses_instances.year as Year,concat(courses_dept_codes.dept_code,courses.number,'-',courses_instances.section) as Course,courses.title as Title,courses_instances.credit_hrs as Credits,courses_instances.projected_enrollment as Enrollment,courses_instances.days,courses_instances.start_time,courses_instances.end_time from courses_instances,courses,courses_dept_codes where person_id=".$rowpeople['id']." and courses.id=courses_instances.course_id and courses.dept_code_id=courses_dept_codes.id and courses_instances.semester='Fall' and courses_instances.year=".$year1."";
$total1=0;
$resultcredits=mysql_query($querycredits);
$numcredits=mysql_num_rows($resultcredits);
if($numcredits==0)
{
$total1=$total1+0;
}
else
{
while($rowcredits=mysql_fetch_array($resultcredits))
{
echo "<tr><td>".$rowcredits['Semester']."</td><td>".$rowcredits['Course']."</td><td>".$rowcredits['Title']."</td><td>".$rowcredits['Credits']."</td><td>".$rowcredits['Enrollment']."</td><td></td><td></td></tr>";
$cre=$rowcredits['Credits'];
$total1=$total1+$cre;
}
}
$querycreditsspring="select courses_instances.semester as Semester,courses_instances.year as Year,concat(courses_dept_codes.dept_code,courses.number,'-',courses_instances.section) as Course,courses.title as Title,courses_instances.credit_hrs as Credits,courses_instances.projected_enrollment as Enrollment,courses_instances.days,courses_instances.start_time,courses_instances.end_time from courses_instances,courses,courses_dept_codes where person_id=".$rowpeople['id']." and courses.id=courses_instances.course_id and courses.dept_code_id=courses_dept_codes.id and courses_instances.semester='Spring' and courses_instances.year=".$year2."";
$resultcreditsspring=mysql_query($querycreditsspring);
$numcreditsspring=mysql_num_rows($resultcreditsspring);
if($numcreditsspring==0)
{
$total1=$total1+0;
}
else
{
while($rowcreditsspring=mysql_fetch_array($resultcreditsspring))
{
echo "<tr><td>".$rowcreditsspring['Semester']."</td><td>".$rowcreditsspring['Course']."</td><td>".$rowcreditsspring['Title']."</td><td>".$rowcreditsspring['Credits']."</td><td>".$rowcreditsspring['Enrollment']."</td><td></td><td></td></tr>";
$cre=$rowcreditsspring['Credits'];
$total1=$total1+$cre;
}
}
$querycreditssummer="select courses_instances.semester as Semester,courses_instances.year as Year,concat(courses_dept_codes.dept_code,courses.number,'-',courses_instances.section) as Course,courses.title as Title,courses_instances.credit_hrs as Credits,courses_instances.projected_enrollment as Enrollment,courses_instances.days,courses_instances.start_time,courses_instances.end_time from courses_instances,courses,courses_dept_codes where person_id=".$rowpeople['id']." and courses.id=courses_instances.course_id and courses.dept_code_id=courses_dept_codes.id and courses_instances.semester Like 'Summer%' and courses_instances.year=".$year2."";
$resultcreditssummer=mysql_query($querycreditssummer);
$numcreditssummer=mysql_num_rows($resultcreditssummer);
if($numcreditssummer==0)
{
$total1=$total1+0;
}
else
{
while($rowcreditssummer=mysql_fetch_array($resultcreditssummer))
{
echo "<tr><td>".$rowcreditssummer['Semester']."</td><td>".$rowcreditssummer['Course']."</td><td>".$rowcreditssummer['Title']."</td><td>".$rowcreditssummer['Credits']."</td><td>".$rowcreditssummer['Enrollment']."</td><td></td><td></td></tr>";
$cre=$rowcreditssummer['Credits'];
$total1=$total1+$cre;
}
}
$ftotal=$total1+$total2;
echo "<tr><td>Total</td><td></td><td></td><td>".$total1."</td><td></td><td></td><td></td></tr>";
echo "</table>";
}
}
$modx->runSnippet('DBdisconnect');
}
?>