There would be no danger in deleting the code. That code simply would free the result if the recordset actually existed. But since you said there is no recordset on that page by the name - that makes the code trying to free the result to become invalid, nonetheless - which will cause the problem you are describing.
Technically, you don't have to free the result ever (except in cases where a query may be reused over and over). But the main reason it is done is to flush the query from the PHP server memory and allow for more efficient applications, so it is good practice (and also the reason DW automatically generates a free result command whenever a recordset is created).
Warmest regards and Happy New Year,