<?php
$old = <<<'NOWDOC'
<?php
// Connect
$link = mysql_connect('mysql_host', 'mysql_user', 'mysql_password')
OR die(mysql_error());
// Query
$query = sprintf("SELECT * FROM users WHERE user='%s' AND password='%s'",
mysql_real_escape_string($user),
mysql_real_escape_string($password));
?>
NOWDOC;
$new = preg_replace('/mysql_([a-zA-Z_]+)\(/', 'mysqli_$1($GLOBALS[\'link\'], ', $old);
$new = str_replace(', )', ')', $new);
echo $new;
preferences:
32.1 ms | 402 KiB | 5 Q