Because the mysql_ extension broke function scope (the last connection made is globally available) and because magic_quotes has also been removed from php, eliminating some of the security for string data values breaking sql query syntax, updating old code requires more than just getting code to work without producing errors. In addition to updating the database extension being used, you need to go through every query that has external, unknown, dynamic data being put into it to insure that it is secure for all types of data.
The best, fool-proof way of insuring that any external, unknown, dynamic data values cannot break the sql query syntax, for all types of data, is to use a prepared query. This involves removing the variables holding the data values from the sql query statement, along with any single-quotes around the values, any {} that may be around the variables, and any concatenation dots, replacing each value in the sql query statement with a ? place-holder, preparing the sql query, and then supplying the actual data values when the query gets executed. You can then write a general query method/function, that accepts the sql query statement and an optional 2nd call-time parameter consisting of an array of the input values. If the 2nd parameter is missing, the code would just use a normal, non-prepared query to directly execute the sql query statement. If the 2nd parameter is used, the code would prepare the sql query statement, then supply the input values when the query gets executed. If you switch to the much simpler PDO extension, doing this is easy, since you can just supply the array of input values directly to the ->execute(…) call. You can also supply an empty array to the ->execute(…) call, so that any dynamically built sql query statements, that may end up without any values being put into them, will work without additional handling.
Approximately how many total mysql_* statements are there and how many mysql_query() statements are in the code making up the project?