All the tables are correct and it’s making the connect to the database fine it’s just not working, did I write it wrong?
[php]function newPm($to, $from, $title, $text){
$q = $db->query(“SELECT * FROM ibf_message_topics ORDER BY mt_id DESC”);
$lastMsg = $db->fetch_assoc($q);
$mid = $lastMsg[‘mt_id’] + 1;
$msgId = $lastMsg[‘mt_msg_id’] + 1;
$db->query(“INSERT INTO ibf_message_topics SET mt_id=$mid, mt_msg_id=$msgId, mt_date=”. time(). “, mt_title=’$title’, mt_from_id=$from, mt_to_id=”. $to. “, mt_vid_folder=‘in’, mt_read=0, mt_owner_id=$to, mt_user_read=0”) or die(mysql_error());
$db->query(“INSERT INTO ibf_message_text SET msg_id=$msgId, msg_date=”. time() .", msg_post=’$text’, msg_sent_to_count=1, msg_author_id=$from") or die(mysql_error());
$userq = $db->query(“SELECT new_msg FROM ibf_members WHERE id = $to”);
$userData = $db->fetch_assoc($userq);
$msgCount = $userData[‘new_msg’] + 1;
$db->query(“UPDATE ibf_members SET new_msg=$msgCount, show_popup=1 WHERE id = $to”) or die(mysql_error());
}[/php]
Here’s how that function is being called in the beginning of the page
[php]if($action ==“banUser”){
$expire = time() + (3600000 * 24 * $_GET[‘duration’]);
$q = $db->query(“SELECT * FROM ibf_message_topics ORDER BY mt_id DESC”);
$lastMsg = $db->fetch_assoc($q);
$mid = $lastMsg[‘mt_id’] + 1;
$msgId = $lastMsg[‘mt_msg_id’] + 1;
$title = “Notification”;
$duration = $_GET[‘duration’] ." days";
if($_GET[‘duration’] == “1”){
$duration = “1 day”;
}
if($_GET[‘duration’] == “Forever”){
$duration = “forever”;
}
$temp = 0;
if($expire > time()){
$temp = 1;
}
$body = “This automated message has been sent to notify you that your account has been banned $duration. To appeal this ban, click on Irc from the menu on the homepage and ask to speak to a moderator. If this ban is temporary, your account will be reinstated automatically at the appropriate time”;
newPm($id, 3017, $title, $body);
$msgCount = $_GET[‘msg’] + 1;
$db->query(“UPDATE ibf_members SET ban_level = $level, tempbanned = $temp, banned = 1, ban_expire=’$expire’, ban_reason=’”. $_GET[‘reason’]."’, ban_by=’". $name."’ WHERE id=$id") or die(mysql_error());
?>
User banned! (Back to Player Management)[/php]