ok, this works now, but adds load to the server and doesn't work on forums, which use multiple boxes, but these problems are very special
Another problem could occur more often. Your hack won't work if a user got a pipe (|) in his username, better to use userid.
My idea was, send all PM notifications just once a day on the first page-impression after midnight.
Do do that add right after:
while ($birthday=$DB_site->fetch_array($bdays)) {
Code:
while ($birthday=$DB_site->fetch_array($bdays)) {
$message = "Your message here.\n";
$title = "Happy Birthday!!";
$DB_site->query("INSERT INTO privatemessage (privatemessageid, userid,touserid, fromuserid,
title, message, dateline, showsignature, iconid, messageread, folderid, receipt) VALUES (NULL,
$birthday[userid],$birthday[userid],1,'$title','$message',".time().",0,0,0,0,0)");