It's easier to pick out errors if you format things to make them easier to read. You are missing a . after your $username inside the query.
PHP Code:
$shouttext = "RACE UPDATE: $race at $qualtime on $qualdate";
$user = 5799;
$username = 'Ladder Admin';
$db->query_write("
INSERT INTO " . TABLE_PREFIX . "chatboxlite_shout
(userid, username, shout, dateline)
VALUES (
" . $user . ",
'" . $username . "',
'" . $db->escape_string($shouttext) . "',
" . TIMENOW . "
)
");