You have no quotes around the text you are adding to the database also add or die(mysql_error()); to the end of your query it will so the errors in the query
<?php
require_once("globals.php");
$i=$db->query("SELECT * FROM uawards WHERE id={$userid}");
$a=$db->fetch_row($i);
if ($a['awardno'] == 1 && $ir['level'] == 5)
{
echo "You are level 5 and you have this award";
}
else if ($ir['level'] == 5)
{
$db->query("INSERT INTO uawards (id, reason, awardno) VALUES ('$userid', 'You got this award for reaching level 5', 1)");
echo "Award Added";
}
$h->endpage();
?>