connect from website to MySQL database

Please forgive in advance as I’m new to PHP and MySQL. I’m using phpMyAdmin v3.4 and MySQL (server version) v5.5. Both the MySQL DB and the website are hosted by JustHost.

I’ve constructed a simple database in MySQL and can’t seem to verify whether I have a connection to it from my website! I’m certain the db_host, db_username, db_password and db_name are correct so I guess the problem is in the syntax of the script (sorry!) i.e. as It’s as though the PHP part of the scrip is completely ignored. I’ve built the script from tutorials and examples. I’m not actually ‘calling’ the script, I simply have the following pasted directly into the HTML webpage (nothing else is on the page and the web pages are JustHost provided templates). You can see I’ve toyed with error_reporting (the php.ini file by default has error_reporting=Off).

Even if I change say the db_name to an incorrect spelling, then refresh the webpage, I still don’t get anything echoed to the screen. The only output echoed to the screen on refresh is the HTML title: PHP call DB. Thanks in anticipation.

<html>
    <head>
        <title>PHP connect to DB</title>
    </head>
    <body>
    <?php
    //ini_set('display_errors',1);
    error_reporting=On;
    error_reporting(E_ALL);
    $db_host = "localhost";
    $db_username = "Peter";
    $db_password = "passwd";
    $db_name = "Res";
    @mysql_select ("$db_host", "$db_username", "$db_password") or die ("could not connect to my sql");
    @mysql_select_db ("$db_name") or die ("No database");
    echo "successful connection";
    ?>
    </body>
</html>

mysql_select() isn't a function.

you are looking for mysql_connect() https://www.php.net/manual/function.mysql-connect.php

that said. you should use the mysqli functions https://www.php.net/manual/intro.mysqli.php