I am having some problems trying to connect to my database. I have used the following code:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Playlists</title>
<meta name="description" content="test">
<meta name="author" content="SitePoint">
<link rel="stylesheet" href="stylesheets.css">
</head>
<body>
<nav>
<a href="index.html"><img src="http://www.samsung.com/us/showcase/milk/img/meta-fb-milk-music.png" alt="Home"></a>
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="">Albums</a></li>
<li><a href="playlist.html">Playlists</a></li>
<li><a href="">About</a></li>
</ul>
</nav>
<div class="content">
<?php
$servername = "localhost";
$username = "username";
$password = "password";
$database = "dbname";
// Create connection
$conn = new mysqli($servername, $username, $password);
// Check connection
if ($conn->connect_error) {
die("not fire" . $conn->connect_error);
}
echo "fire";
@mysql_select_db($database) or die( "Unable to select database");
mysql_close();
?>
</div>
</body>
</html>
Of course these are not my real login names, but these are definitely right. When I open the page it says: "fireUnable to select database" So the connection with the server is going okay, but the connection to the database isn't. Can someone help me out?