Since you're getting a specific resource ID in the error message, the database connection likely closed unexpectedly for some reason. Your program still has a variable with a resource ID, but the external object no longer exists. This may be due to a
mysql_close() call somewhere before the call to
mysql_query, or an external database error that closed the connection.