Hi,
As you might have guessed, I'v written some code and I have problems with it.
I've written a bot-recognising page on my forum, which recognises bots and alerts when there are non-bot people who need to be set the right permissions.
Giving the permissions is done by checking the box right of their name and say add permissions.
The bot recognising, removal, ... everything works fine, except adding the right permissions to the non-bot users.
This is done by adding them to a group on the forum which will allow them to post on all parts of the forum.
But somehow I get an error there...
This is very strange, because the line it points to is indeed a line with mysql_fetch_array(), but a bit further in my code, I use the exact same code again, with the same mysql request, and it doesn't give an error there.
Doesn someone knows how to solve this error, or can someone find the error in my code?
Thanks in advance.
As you might have guessed, I'v written some code and I have problems with it.
I've written a bot-recognising page on my forum, which recognises bots and alerts when there are non-bot people who need to be set the right permissions.
Giving the permissions is done by checking the box right of their name and say add permissions.
The bot recognising, removal, ... everything works fine, except adding the right permissions to the non-bot users.
This is done by adding them to a group on the forum which will allow them to post on all parts of the forum.
But somehow I get an error there...
| Quote: |
| Warning: mysql_fetch_array(): 22 is not a valid MySQL result resource in /home/ecthelio/domains/teamfsn.frih.net/public_html/phpBB2/removebot.php on line 71 |
This is very strange, because the line it points to is indeed a line with mysql_fetch_array(), but a bit further in my code, I use the exact same code again, with the same mysql request, and it doesn't give an error there.
Doesn someone knows how to solve this error, or can someone find the error in my code?
Thanks in advance.
| Code: |
| if($userdata['user_level'] == ADMIN){
$sql = "SELECT u.user_id , u.username, u.user_posts FROM phpbb_users u WHERE u.user_active =1 AND u.user_lang = 'french' AND u.user_id <>-1"; if ( !($result = $db->sql_query($sql)) ){ message_die(GENERAL_ERROR, 'Error getting group information', '', __LINE__, __FILE__, $sql); } //Then see if we have to add someone to the non-bot list while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { // <<<===== The error points to this line $sql2 = "SELECT u.user_id, u.username FROM phpbb_users u, phpbb_user_group g WHERE g.group_id = 32 AND u.user_id = " . $line['user_id'] . " AND g.user_id = u.user_id"; if ( !($result2 = $db->sql_query($sql2)) ) { message_die(GENERAL_ERROR, 'Error getting group information', '', __LINE__, __FILE__, $sql); } if($line2 = mysql_fetch_array($result2, MYSQL_ASSOC)){ //The user is in the group, do nothing }else{ //Did the user post anything? if($line['user_posts'] != 0){ //The user was not found in the group, so print the result an set toactivate on 1 $toactivate = 1; //Do we have to activate him? $toadd = "add_" . $line['user_id']; //echo $line['user_id']; if(isset($HTTP_GET_VARS[$toadd])){ ?> <table width="90%" border="0" align="center" cellpadding="0" cellspacing="0" background="templates/aqua/images/aquatbm.gif"> <tr align="center" background="templates/aqua/images/aquatbm.gif"> <td width="33%" height="22" align="left"><img src="templates/aqua/images/aquatbl.gif" width="22" height="22"></td> <td width="33%" height="22" align="center"><span class="cattitle"> </span></td> <td width="33%" height="22" align="right"><img src="templates/aqua/images/aquatbr.gif" width="79" height="22"></td> </tr> </table> <table width="90%" border="0" align="center" cellpadding="0" cellspacing="0" class="forumline"> <tr> <th class="thHead" height="25" align="center"><span class="tableTitle"> Vous avez ajouté <? echo $line['username'] ?>aux groupe 'Vivants'! </span></th><th class="thHead" height="25" align="left"></th> </tr> <table width="90%" height="22" border="0" align="center" cellpadding="0" cellspacing="0" background="templates/aqua/images/aquatbdm.gif"> <tr> <td><img src="templates/aqua/images/aquatbdl.gif"></td> <td align="right"><img src="templates/aqua/images/aquatbdr.gif"></td> </tr></table></br> <? //And now add him for real $sql3 = "INSERT INTO `phpbb_user_group` (group_id, user_id, user_pending) VALUES(32," . $line['user_id'] . " ,0)"; $db->sql_query($sql3); }//End isset }//end number of post $db->sql_freeresult($result2); }//end if in group $db->sql_freeresult($result); }//end while }//end userlevel |
