I've been getting the following error and I don't know how to fix it.  Uncaught Error: Call to undefined function mysql_real_escape_string(). I've been reading some articles on here on how to fix it, but I still am having issues doing so. I tried making it mysqli instead of mysql and then I get more errors that I don't know how to fix such as mysqli_real_escape_string() expects exactly 2 parameters. I don't understand that error because I believe I have two parameters. Here is the part of my code where I am having issues. 
require_once 'gen.php';
govdocs_cropandresize($dst_img, $src_img);
imagedestroy($src_img);
govdocs_save_image($dst_img, $link, $group);
imagedestroy($dst_img);
unlink($tmp_name);
header('Location: index.php' . ($group != NULL ? '?g=' . $group : ''));
function govdocs_save_image(&$dst_img, $link = '', $group = '1322715600', $quality = 100) {
    $img = imagejpeg($dst_img, $GLOBALS['tmp_name'], $quality);
    $img_str = mysqli_real_escape_string(file_get_contents($GLOBALS['tmp_name'])); 
    $link = mysql_real_escape_string($link);
    $group = mysql_real_escape_string($group);
    $query = "INSERT INTO govdocs_images (`group`, `link`, `image`) VALUES (FROM_UNIXTIME(" . $group . "),'" . $link . "','" . $img_str . "')";
    if (!mysql_query($query)) {
        // The generated image is too big, so reduce the quality a little bit until it is small enough.
        govdocs_save_image($dst_img, $link, $group, $quality - 5);
//      echo mysql_error();
    }
}
Thank you for the help. I am very new to this and have read a lot of articles but still can't figure it out. NOTE: This code did work correctly before upgrading to PHP 7.
