PHP: Connect to a database in MySQL

$link = mysql_connect($host, $user, $password);
if ($link && mysql_select_db($db))
{}

$sql = “select * from table”;
$res = mysql_query($sql);
if (! $res) die (“Could not run query”);
$no_recs = mysql_num_rows($res);
i = 0;
while ($row = mysql_fetch_array($res))
{
$i++; $first = $row[“FirstName”]; $last = $row[“LastName”];
}

mysql_free_result($res);
mysql_close($link);