Php 5.2 to php 7.2

How do I upgrade this line to php 7.2
$link = mysql_connect($mysql_server, “ics”, “ics-server”) or die

Because magic_quotes were also remove from php, updating old mysql_ based code requires more than just getting the database statements to work using a new extension. You must also make sure that you prevent any sql special characters in data from breaking the sql query syntax, which is how sql injection is accomplished. Also, using or die(…) for error handling was never a good idea.

If you switch to the PDO extension, use a prepared query when supplying external, unknown, dynamic values when the query gets executed, use implicit binding (supply an array of input values to the ->execute([…]) call), and use exceptions for errors and in most cases just let php catch and handle the exception, it will simplify the implementation of the database related code/query(ies.) You can actually remove, rather than convert a lot of the old code/syntax. If the application isn’t already separating the database specific code, that knows how to query for and retrieve the data, from the presentation code, that knows how to produce the output from the data, this would be a good time to make this change too.

Approximately how many sql queries are there in the entire application?

Sponsor our Newsletter | Privacy Policy | Terms of Service