$query = "select `users`.`fname` as `fname`, `email`.`id` as `id`, `email`.`email` as `email` from `users`,`email`
where `users`.`verified`=0 and
(UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(`users`.`created`)) >= 300 and
`users`.`id`=`email`.`memid` and `users`.`email`=`email`.`email`";
$res = mysql_query($query);
while($row = mysql_fetch_assoc($res))
{
$rnd = fopen("/dev/urandom", "r");
$hash = md5(fgets($rnd, 64));
fclose($rnd);
mysql_query("update `email` set `hash`='$hash' where `id`='".$row['id']."'");
$body = "Hi ".$row['fname']."\n\n";
$body .= "Due to some bugs with the new website we initially had issues with emails being sent out. This email is being sent to those effected so they can be re-sent their email probe to over come earlier issues. We apologise for any inconvenience this may have cause. To verify your account, simply click on the link below.\n\n";