I have been trying to get this to work for two days now, but it refuses to work. The page I am constructing allows an administrator to assign or unassign a recruiter from a list of members within a table.
here is the function:
#################################################
## ##
## Member Drop-Down Menu ##
## member_dropdown($link) ##
## ##
## This Function lists all current members ##
## ##
#################################################
function member_dropdown($link)
{
mysql_select_db(trinitypa, $link) or DIE("The Database Could Not Be Found or is Unavailable!");
$userQuery =
"
SELECT
$table_200.user_id,
$table_200.username
FROM
$table_200,
$table_201
WHERE
$table_200.user_id = $table_201.user_id
AND
$table_201.group_id = '4'
AND
$table_200.user_active = '1'
";
$userResults = mysql_query($userQuery, $link);
WHILE($row = mysql_fetch_array($userResults))
{
PRINT("<option value='$row[0]'>$row[1]</option>");
}
}
//*******************************************
Ok and here is the code that is calling it-
//*******************************************
####################
## Print Out Form ##
####################
Print("
<br><br>
<center>
<span class='infoHeader1'>ASSIGN A RECRUITER</span>
<form method='post' action='$PHPSELF'>
<table width='100%' border='0' bgcolor='#FFCCCC'>
<tr>
<td width='30%'><b>Assign as Recruiter:</b></td>
<td width='70%'><select name='user_id'>");
member_dropdown($link);
Print("
</select></td>
</tr>
<tr>
<td width='30%'> </td>
<td width='70%'> </td>
</tr>
<tr>
<td width='30%'> </td>
<td width='70%'>
<input type='submit' name='Submit' value='Assign as Recruiter'>
</td>
</tr>
</table>
<table width='100%' border='0' bgcolor='#6699FF'>
<tr>
<td valign='top' width='30%'><b>Current Assignment(s):</b><br></td>
<td width='70%'>\n");
// Output the existing Assignments and place a radio in front for delete selection.
while ($row = mysql_fetch_row($Result)){
echo "<input type='radio' name='delete_recruiter_id' value='$row[0]'><b>$row[1]</b><br>\n";
}
Print ("
</td>
</tr>
<tr>
<td width='30%'> </td>
<td width='70%'>
<input type='submit' name='delete' value='Un-Assign This Recruiter'>
</td>
</tr>
</table>
</form>
<p> </p>
<p><font size='6' color='blue'>$message</font></p>
</center>
");
I have the $link variable assigned at the top of the page. $link is the mysql user, host and password- it is connecting because it is not throwing or my or DIE("Problem with First DB SELECT") statement. But when it calls this function (which is in an INCLUDED file, it gives the following error:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in home/path/www/otherpath/INCLUDES/functions.php</b> on line <b>38
Line 38 is the while statement in the Function listed above (userResults).
I am in need of a fresh pair of eyes on this- can anyone see if I am doing something wrong?