I've been staring at this error for about an hour now and cannot figure it out for the life of me. Tried looking at a few other threads on here and they all seemed to suggest a failed connection to my db, but that shouldn't be the issue as I'm using the same method of connecting to the db on several other pages that ARE working fine.
Any help troubleshooting this code would be much appreciated! Purpose of the code is to load data from a table and create an excel export.
The full error code is:
Warning: mysql_num_fields(): supplied argument is not a valid MySQL result resource in /home/therefli/public_html/iowareferees/modules/registrarTools_registrationDownloadBatch.php on line 39
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/therefli/public_html/iowareferees/modules/registrarTools_registrationDownloadBatch.php on line 44
The code creating the issue:
include("../classes/databaseConnection.php");
$select_recert = "
SELECT ' ', ' ', ' ', uRegBATCHID, '$date_download', ' ', ' ', ' ', uUSID, '1', '2',
uRegYEAR, uRegLAST, uRegFIRST, ' ', uRegADDRESS, ' ', uRegCITY, uRegADDRSTATE, uRegZIP, uRegGENDER,
uRegDATEOFBIRTH, uRegNATIONBIRTH' ', uRegNATIONCITIZEN' ', uRegPHONE1, ' ', uRegGRADE, uRegSTATE,
uRegEMAIL, ' ', uRegFIRSTREGISTERED, ' ', ' ', ' ', ' ', uRegFELONY, uRegDATE, '', '', uRegUID
FROM usersRegistration
WHERE uRegSTATUS='registered'
AND uRegACTION='recert'
AND uRegCLASS='Referee'
AND uRegYEAR='$VAR[regyear_year]'
AND uRegBATCHID=$batch_number
ORDER BY uRegLAST";
$export_recert = mysql_query($select_recert);
$fields_recert = mysql_num_fields($export_recert);
for ($i = 0; $i < $fields_recert; $i++) {
$header_recert .= mysql_field_name($export_recert, $i) . "\t";
}
//EXTRACT DATA
while($row = mysql_fetch_row($export_recert)) { // this is line 39
$line = '';
foreach($row as $value_recert) {
if ((!isset($value_recert)) OR ($value_recert == "")) {
$value = "\t";
} else {
$value_recert = str_replace('"', '""', $value_recert);
$value_recert = '"' . $value_recert . '"' . "\t";
}
$line .= $value_recert;
}
$data_recert .= trim($line)."\n";
}
$data_recert = str_replace("\r","",$data_recert);
Thanks so much in advance!!