How to connect to MySQL with PHP

Programming, error messages and sample code > sample code
<h1>MySQL Test Code Results</h1> 
<p><table border="1"
<tr> 
<td>ID</td> 
<td>First Name</td> 
<td>Last Name</td> 
</tr> 
 
<?php 
 
// Configuration Information and Definitions 
 
$mysql_host = 'MySQL Server Name'
$mysql_user = 'DB Login'
$mysql_pass = 'DB Password'
$mysql_db = 'DB Name'; 
$query = 'SELECT * from table1'
 
$con = mysqli_connect($mysql_host, $mysql_user, $mysql_pass) or die("Connection to MySQL-server failed!");
 
mysqli_select_db($con, $mysql_db) or die("Selection of database $mysql_db failed!");
 
$result = mysqli_query($con, $query) or die("Invalid Query, " . mysql_error());
 
while( list( $pkid, $fname, $lname ) = mysqli_fetch_row($result) ) {
printf("<tr><td>%d</td><td>%s</td><td>%s</td></tr>", $pkid, $fname, $lname); 
 
?> 
</table> 
</> 
<b>End MySQL Test Code Results</b>