PHP: Read MySQL Database with cookie validation

list ($username, $pwd) = split(“ “, $validation);
if (empty($username) || empty($pwd)) die (“You are not authorized user”);
$connection = @mysql_connect($host, $username, $pwd) or die (“Could not connect to database”);
$db = mysql_select_db(“address”, $connection) or die (“Could not select database”);

$sql = “select * from table”;
$res = mysql_query($sql);
if (! $res) die (“Could not read records”);
$no_recs = mysql_num_rows($res);

while ($row = mysql_fetch_array($res))
{
$i++
$first = $row[“FirstName”];
$last = $row[“LastName”];
}

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