MySQL 5.7 connect via PHP on FTP

i have a pretty annoying problem. I can not connect to my MySQL 5.7 database using php file on my ftp.

    <?php
$localhost = "database_webpage";
$user = "user";
$password = "password";
$databaze = "one_of_my_table";
mysql_connect($localhost, $user, $password);
    or die("Error_1: Could not connect to database");
mysql_select_db($databaze)
               or die("Error_2: Could not choose the database");
?>

I have this code saved on mac via TextEdit as php file. But everytime, when i connect to this file on my ftp, i get only the same, which is in the file and not Error_1: Could not connect to database or Error_2: Could not choose the database

What am i doing wrong?

Try with this code

<?php 
/* Database connection settings */
$user = "user";
$password = "password";
$db = "one_of_my_table";
$port = "3306";
$host = "localhost";

$connection = mysqli_connect("$host","$user","$password","$db");

if($connection){ 
echo "Ok"
}
else{echo "Error"}

?>