I'm using very basic code- here it is. The unusual part is that the random numbers are always no less or more than a total of eight. The field that is being duplicated is "sentfrom". Thank you for looking.
$query = "insert into mailbox
(userid, sentfrom, sentto, mail_id, subject, message, messagesent)
values ('$userid', '$sentfrom', '$sentto', '$mail_id', '$subject', '$message', now())";