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');
}
?>

run this and then post your results if you can't figure it out at that point.

<?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'];

$dberrors = array();

$dbdebug = true; //set to false to not display database errors

//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');
	mysql_query("begin");
	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";
	}

	if(!$resultpeople=mysql_query($querypeople))
	{
		$dberrors[] = "query failed: " . $querypeople . " - " . mysql_error();
	}
	$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;
			if(!$resultcredits=mysql_query($querycredits))
			{
				$dberrors[] = "query failed: " . $querypeople . " - " . mysql_error();
			}
			$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']."";
			if(!$resultcreditsspring=mysql_query($querycreditsspring))
			{
				$dberrors[] = "query failed: " . $querypeople . " - " . mysql_error();
			}
			$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']."";
			if(!$resultcreditssummer=mysql_query($querycreditssummer))
			{
				$dberrors[] = "query failed: " . $querypeople . " - " . mysql_error();
			}
			$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>";
	
	if(count($dberrors) > 0)
	{
		echo "there were " . count($dberrors) . " database errors:transaction rolled back<br />";
		mysql_query("rollback");
		echo $dbdebug?implode("<br />", $dberrors):"";
	}
	else
	{
		mysql_query("commit");
	}
	$modx->runSnippet('DBdisconnect');
}
else if($details==1)
{
	$modx->runSnippet('DBConnect');
	mysql_query("begin");
	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";
	}

	if(!$resultpeople=mysql_query($querypeople))
	{
		$dberrors[] = "query failed: " . $querypeople . " - " . mysql_error();
	}

	$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;
			if(!$resultcredits=mysql_query($querycredits))
			{
				$dberrors[] = "query failed: " . $querypeople . " - " . mysql_error();
			}
			$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."";
			if(!$resultcreditsspring=mysql_query($querycreditsspring))
			{
				$dberrors[] = "query failed: " . $querypeople . " - " . mysql_error();
			}
			$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."";
			if(!$resultcreditssummer=mysql_query($querycreditssummer))
			{
				$dberrors[] = "query failed: " . $querypeople . " - " . mysql_error();
			}
			$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>";
		}
	}
	
	if(count($dberrors) > 0)
	{
		echo "there were " . count($dberrors) . " database errors:transaction rolled back<br />";
		mysql_query("rollback");
		echo $dbdebug?implode("<br />", $dberrors):"";
	}
	else
	{
		mysql_query("commit");
	}
	$modx->runSnippet('DBdisconnect');
}
?>

Umm..no I am still getting this error:

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: 69

<?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'];

$dberrors = array();

$dbdebug = true; //set to false to not display database errors

//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');
	mysql_query("begin");
	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";
	}

	if(!$resultpeople=mysql_query($querypeople))
	{
		$dberrors[] = "query failed: " . $querypeople . " - " . mysql_error();
	}
	$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;
			if(!$resultcredits=mysql_query($querycredits))
			{
				$dberrors[] = "query failed: " . $querypeople . " - " . mysql_error();
			}
			$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']."";
			if(!$resultcreditsspring=mysql_query($querycreditsspring))
			{
				$dberrors[] = "query failed: " . $querypeople . " - " . mysql_error();
			}
			$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']."";
			if(!$resultcreditssummer=mysql_query($querycreditssummer))
			{
				$dberrors[] = "query failed: " . $querypeople . " - " . mysql_error();
			}
			$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>";
	
	if(count($dberrors) > 0)
	{
		echo "there were " . count($dberrors) . " database errors:transaction rolled back<br />";
		mysql_query("rollback");
		echo $dbdebug?implode("<br />", $dberrors):"";
	}
	else
	{
		mysql_query("commit");
	}
	$modx->runSnippet('DBdisconnect');
}
else if($details==1)
{
	$modx->runSnippet('DBConnect');
	mysql_query("begin");
	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";
	}

	if(!$resultpeople=mysql_query($querypeople))
	{
		$dberrors[] = "query failed: " . $querypeople . " - " . mysql_error();
	}

	$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;
			if(!$resultcredits=mysql_query($querycredits))
			{
				$dberrors[] = "query failed: " . $querypeople . " - " . mysql_error();
			}
			$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."";
			if(!$resultcreditsspring=mysql_query($querycreditsspring))
			{
				$dberrors[] = "query failed: " . $querypeople . " - " . mysql_error();
			}
			$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."";
			if(!$resultcreditssummer=mysql_query($querycreditssummer))
			{
				$dberrors[] = "query failed: " . $querypeople . " - " . mysql_error();
			}
			$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>";
		}
	}
	
	if(count($dberrors) > 0)
	{
		echo "there were " . count($dberrors) . " database errors:transaction rolled back<br />";
		mysql_query("rollback");
		echo $dbdebug?implode("<br />", $dberrors):"";
	}
	else
	{
		mysql_query("commit");
	}
	$modx->runSnippet('DBdisconnect');
}
?>

This should output the sql query that is failing, if so post the sql query.

<?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'];

$dberrors = array();

$dbdebug = true; //set to false to not display database errors

//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');
	mysql_query("begin");
	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";
	}

	if(!$resultpeople=mysql_query($querypeople))
	{
		echo $dbdebug?$querypeople . "<br />":"";
		$dberrors[] = "query failed: " . $querypeople . " - " . mysql_error();
	}
	$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;
			if(!$resultcredits=mysql_query($querycredits))
			{
				echo $dbdebug?$querycredits . "<br />":"";
				$dberrors[] = "query failed: " . $querycredits . " - " . mysql_error();
			}
			$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']."";
			if(!$resultcreditsspring=mysql_query($querycreditsspring))
			{
				echo $dbdebug?$querycreditsspring . "<br />":"";
				$dberrors[] = "query failed: " . $querycreditsspring . " - " . mysql_error();
			}
			$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']."";
			if(!$resultcreditssummer=mysql_query($querycreditssummer))
			{
				echo $dbdebug?$querycreditssummer . "<br />":"";
				$dberrors[] = "query failed: " . $querycreditssummer . " - " . mysql_error();
			}
			$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>";
	
	if(count($dberrors) > 0)
	{
		echo "there were " . count($dberrors) . " database errors:transaction rolled back<br />";
		mysql_query("rollback");
		echo $dbdebug?implode("<br />", $dberrors):"";
	}
	else
	{
		mysql_query("commit");
	}
	$modx->runSnippet('DBdisconnect');
}
else if($details==1)
{
	$modx->runSnippet('DBConnect');
	mysql_query("begin");
	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";
	}

	if(!$resultpeople=mysql_query($querypeople))
	{
		echo $dbdebug?$querypeople . "<br />":"";
		$dberrors[] = "query failed: " . $querypeople . " - " . mysql_error();
	}

	$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;
			if(!$resultcredits=mysql_query($querycredits))
			{
				echo $dbdebug?$querycredits . "<br />":"";
				$dberrors[] = "query failed: " . $querycredits . " - " . mysql_error();
			}
			$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."";
			if(!$resultcreditsspring=mysql_query($querycreditsspring))
			{
				echo $dbdebug?$querycreditsspring . "<br />":"";
				$dberrors[] = "query failed: " . $querycreditsspring . " - " . mysql_error();
			}
			$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."";
			if(!$resultcreditssummer=mysql_query($querycreditssummer))
			{
				echo $dbdebug?$querycreditssummer . "<br />":"";
				$dberrors[] = "query failed: " . $querycreditssummer . " - " . mysql_error();
			}
			$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>";
		}
	}
	
	if(count($dberrors) > 0)
	{
		echo "there were " . count($dberrors) . " database errors:transaction rolled back<br />";
		mysql_query("rollback");
		echo $dbdebug?implode("<br />", $dberrors):"";
	}
	else
	{
		mysql_query("commit");
	}
	$modx->runSnippet('DBdisconnect');
}
?>

Yes it does.

Here's the complete error message

line 62

select sum(credit_hrs) as fallfte from courses_instances where year= and semester='Fall' and person_id=1074

MODx encountered the following error while attempting to parse the requested resource:
« PHP Parse Error »

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: 71

Yes it does.

Here's the complete error message

line 62

select sum(credit_hrs) as fallfte from courses_instances where year= and semester='Fall' and person_id=1074

MODx encountered the following error while attempting to parse the requested resource:
« PHP Parse Error »

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: 71

looking at the query you need something for year where you year= and. What the parser is doing is it is not seeing anything to compare year to so it goes to the next word which is "and" which eliminates your "and" from the query which throws the whole thing off. It is equivalent to saying
"select sum(credit_hrs) as fallfte from courses_instances where year= 'and' semester='Fall' and person_id=1074"

See what I mean? If you need the possibility of having a blank year then you need to surround that variable with single quotes so that the parser can evaluate it correctly.

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.