警告:mysql_affected_rows()期望参数1是资源但没有错误[重复]

$sql2 = "INSERT IGNORE INTO table (word) VALUES ('test')"; 
$result2 = mysql_query($sql2);
if (!$result2){
    throw new My_Db_Exception('Database error: ' . mysql_error());
} else {
    echo "OK";  
}
$affected_rows = mysql_affected_rows($result2);

I know there are a ton of posts on this topic, but I am truly stumped on this. For some reason my query returns

Warning: mysql_affected_rows() expects parameter 1 to be resource, boolean given

As you can see below I am running an if statement to determine what the error is, but this statement returns "OK" as if there is no issue.

The warning message only comes when I want to use a mysql_num_rows or mysql_affected_rows

I know that mysql_affected_rows is what I really want for my INSERT IGNORE, but I tested out mysql_num_rows for kicks and returns same error.

Even if I run this exact query in phpmyadmin I get

phpmyadmin error

What am I not seeing? I am getting no errors except for the Warning: mysql_affected_rows() expects parameter 1 to be resource

UPDATE SOLVED

It was due to mysql_affected_rows was grabbing a previous connection to a DB so I had to pass the query as $affected_rows = mysql_affected_rows(); with no connection specified. Since the connection it was using was passing TRUE that is the reason no errors were being thrown.

</div>