从php连接到mysql无声地失败

I'm trying to connect to a server running on linux from a php file using the following file:

<?php
    $db_host = "127.0.0.1";
    $db_user = "userk";
    $db_pss = "pass";

    $tag = $_POST['tag'];
    echo $tag . " Trying to connect with credentials: "
         . $db_host."
". $db_user . " " .$db_pss;

    $link = mysql_connect($db_host, $db_user,$db_pss);
    if (!$link) {
        die('Could not connect: ' . mysql_error());
    }
    echo 'Connected successfully';
    mysql_close($link);
?>

the output page is:

register Trying to connect with credentials: 127.0.0.1 userk pass

I've checked previous questions looking for useful information. But it still doesn't work.

I'm able to connect to mysql with this user from terminal using putty. I don't know why I don't receive any messages after the connection attempt. Should I check the firewall configuration on the server, how can I check that?

Thanks!

<?php
$db_host = "localhost";
$db_user = "userk";
$db_pss = "pass";

$tag = $_POST['tag'];
echo $tag . " Trying to connect with credentials: " . $db_host."
". $db_user . " " .$db_pss;

$link = mysql_connect($db_host, $db_user,$db_pss);
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
?>

try this :)

As we know mysql_* is depreciated now, so better use it using MYSQLI_*:

<?php
error_reporting(E_ALL | E_NOTICE | E_STRICT );
$db_host = "localhost";
$db_user = "userk";
$db_pss = "pass";
$database="abc";

$tag = $_POST['tag'];
echo $tag . " Trying to connect with credentials: " . $db_host."
". $db_user . " " .$db_pss" " .$database;

$link = mysqli_connect($db_host, $db_user,$db_pss,$database);
if (!$link) {
die('Could not connect: ' . mysqli_error($link));
}
echo 'Connected successfully';
mysqli_close($link);
?>

It can be a case that your errors are suppressed. So its not showing an error. try it out. It will give the error now. That will help figuring out real problem.:)