I have a PHP script thus:
$result = $Student->find_student($real_search_criteria, $real_search_term);
if(!$result || ($rows_returned = mysql_num_rows($result)) == 0)
{
echo '<tr><td colspan="5">No students found</td></tr>';
} else {
for($i = 0; $i < $rows_returned; $i++)
{
$details = mysql_fetch_array($result);
echo '<tr>';
echo "<td>".$details[0]."</td>";
echo '<td>'.$details[membership_index].' </td>';
echo '<td>'.$details[surname].' </td>';
echo '<td>'.$details[forename].' </td>';
echo '<td>'.$Student->get_status_text($details[status]).' </td>';
echo '</tr>';
}
}
Whenever I run the script and get more than 1 result I get a "mysql_fetch_array() 8 is not a valid MySQL result resource" error. If I remove the call to $Student->get_status_text() then the error goes away.
The code for get_status_text is:
function get_status_text($status)
{
$status_text_result = mysql_query("select status_text from pma_training_status where status_code = '".$status."'");
if($status_text_result)
{
$status_text_result_array = mysql_fetch_array($status_text_result);
return $status_text_result_array[0];
} else {
die("Student: Poor SQL select in get_status_text");
}
}
It's as though running a second query has removed the results of the first but I've run these sort of scripts on other domains with no problem.
Is it a setting in the MySQL setup or can you not have 2 result sets on the go at once?