WarningThis function was deprecated in PHP 5.3.0, and it and the entire original MySQL extension was removed in PHP 7.0.0.
Instead, use either the actively developed MySQLi or PDO_MySQL extensions.
Using mysql_db_query() give error: Deprecated: mysql_db_query(): This function is deprecated; use mysql_query()
$query = "select $session_value from $tb_sessions where $session_key = '$key' and $session_time > UNIX_TIMESTAMP()";
$result = mysql_db_query($dbname, $query, $sdbh);
To fix this you can rewrite as:
$conn = mysqli_connect("localhost","$mysql_user","$mysql_password","$dbname");
$query = "select $session_value from $tb_sessions where $session_key = '$key' and $session_time > UNIX_TIMESTAMP()";
$result = mysqli_query ($conn,$query);
Previous page: The Basics of PHP Objects
Next page: Mysql