mysql_select_db无法在localhost上工作[重复]

This question already has an answer here:

I have installed wamp server and am working on localhost.I am trying to connect database with following code

 <?php

$servername = "localhost";
$username = "";
$password = "";
$database ="weddingapp";
// Create connection
$conn = mysqli_connect($servername, $username, $password);
// Check connection
if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());
}
mysqli_select_db("$database", $conn);
echo "Connected successfully";

?>

Connected successfully is coming along with error

Warning: mysqli_select_db() expects parameter 1 to be mysqli, string given in C:\wamp\www\Wedding-app\config.php on line 13

I am new to PHP help me in this Thanks in advance

</div>

try with this

Code:-

<?php

$servername = "localhost";
$username = "";
$password = "";
$database ="weddingapp";
// Create connection
$conn = mysql_connect($servername, $username, $password);
// Check connection
if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());
}
mysql_select_db($database, $conn);
echo "Connected successfully";

?>

Mistake is you have given "$database" in line num:13 remove.

$conn = mysqli_connect($servername,$username,$password,$database) or die("Error " . mysqli_error($conn)); 

you are not giving user name, change to $username = "root";

Its clearly showing an error

mysql_select_db("$database", $conn);
                ^^^^^^^^^^^^^^^^^^

It must be

mysql_select_db($conn,$database);

Try to learn the function

mysqli_select_db ( mysqli $link , string $dbname )

SideNote: You were using deprecated mysql version start using mysqli or PDO