This question already has an answer here:
I'm working on a system for my school that lets the teachers post any notices they have for the day on the intranet. However I got this error when testing it out:
Warning: mysqli_select_db() expects exactly 2 parameters, 1 given in C:\Users\Matthew\Desktop\wamp64\www\my-site\viewguestbook.php on line 23.
Here is the page's code:
<?php
$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="test"; // Database name
$tbl_name="guestbook"; // Table name
// Connect to server and select database.
mysqli_connect("$host", "$username", "$password")or die("cannot connect server ");
mysqli_select_db("$db_name")or die("cannot select DB");
$sql="SELECT * FROM $tbl_name";
$result=mysqli_query($sql);
while($rows=mysqli_fetch_array($result)){
?>
Note: This is different to the other questions of this same name on the website as it's in a different circumstance.
</div>