Hi I am trying to learn how to use PHP with MySQL but I can't get it to work. I can't run a simple SELECT query because I can't connect my database. Here is the code for how to tried to connect it.
//Creates connection
$conn = new mysqli($servername, $username, $password);
$link = mysql_connect($servername, $username, $password);
//Checks connection
if ($conn->connect_error) {
die("Connection failed: ".$conn->connect_error);
}
mysql_select_db($db, $link);
echo "Connection Successful<br>";
The $link
and $conn
variables are repetitive on purpose because I'm not sure which method to use.