The migration sections in the php.net appendices list the backward incompatible changes, removed, and deprecated features that you must update to get your code to even work and to future-proof your code - PHP: Appendices - Manual
Since you must update the database extension, from the now removed mysql extension, you will need to address protecting queries from sql special characters in data values breaking the sql query syntax, which is how sql injection is accomplished, and having error handling for the database statements that can fail - connection, query, prepare, and execute. Prepared queries provide protection, for all data types, not just strings, and actually simplifies the sql query syntax (all the quotes, dots, and {} used to get php variables into the sql statement go away), and eliminates all of the php code to try and make each different data type safe. You would also use implicit binding (supply an array of values to the execute() call) and for error handling use exceptions for database statements and only catch and handle the exception in your code for user recoverable errors, such as when inserting/updating duplicate or out of range user submitted values. For all other error conditions, just let php catch and handle any database exception.
Doing the above will eliminate most of the existing database implementation logic, so that you don’t need to update it, you can just delete it. All you need to do is trim, then validate input data to insure it meets the needs of your application. The prepared query handles security and exceptions handle errors.