Page 1 of 1
Check this out. I am trying to send the PM id in the message
Posted: Sun Dec 11, 2005 1:04 am
by davidprogramer
Code: Select all
$message = "
Clan Name : $clan_name
Clan Tag : $clan_tag
Clan Status : $clan_status
Honor : $clan_honor
Ladder Name : $ladder_name
Clan Rank : $clan_rank
Clan Points : $clan_points
Clan Win % : $clan_winpercent %
Clan Wins/Losses : $clan_wins / $clan_losses
Clan Streak : $clan_streak
Clan Started on $clan_regdate
url=www.aowars.com/modules.php?name=League&file=join_clan&op=accept&lid=$current_ladder&sid=$sending_user&pid=$recieving_playerid&cid=$clan_id]<< ACCEPT >>/url]
url=www.aowars.com/modules.php?name=League&file=join_clan&op=reject&lid=$current_ladder&sid=$sending_user&pid=$recieving_playerid&cid=$clan_id]<< REJECT >>/url] ";
// Begin sending the PM.
$pm_subject = "Clan Invite from $clan_tag";
$privmsgs_date = time();
$recieving_user_profile = sql_query("SELECT user_id, username FROM ".$prefix."_users WHERE user_id = $recieving_user");
list($user_id, $username) = sql_fetch_row($recieving_user_profile);
$message = "$message";
$subject = "Clan Invite from $clan_tag";
if(empty($message) || empty($subject)) {
return;
}
$bbcode_uid = make_bbcode_uid();
$privmsg_message = prepare_message($message, 1, 1, 1, $bbcode_uid);
$sql = "INSERT INTO nuke_bbprivmsgs (privmsgs_type, privmsgs_subject, privmsgs_from_userid, privmsgs_to_userid, privmsgs_date ) VALUES ('1', '".$subject."', '$sending_user', '$recieving_user', ".$privmsgs_date.")";
if ( !$db->sql_query($sql, BEGIN_TRANSACTION) )
{
echo "Could not insert private message sent info";
}
$privmsg_sent_id = $db->sql_nextid();
$privmsgs_text = $message;
$sql = "INSERT INTO nuke_bbprivmsgs_text (privmsgs_text_id, privmsgs_bbcode_uid, privmsgs_text) VALUES ('".$privmsg_sent_id."', '".$bbcode_uid."', '".$privmsg_message."')";
if ( !$db->sql_query($sql, END_TRANSACTION) )
{
echo "Could not insert private message sent text";
}
$sql = "UPDATE nuke_users
SET user_new_privmsg = user_new_privmsg + 1, user_last_privmsg = '" . time() . "'
WHERE user_id = '$recieving_user'";
if ( !($result = $db->sql_query($sql)) )
{
echo "Could not update users table";
}
See how the message is made above the queries? Well I can't think of ANY way to get the PM id inside the message. Can you guys think of a way. I am doing this so that after a player accepts or rejects an invite, it deletes the PM.
Posted: Sun Dec 11, 2005 4:54 pm
by davidprogramer
bump~
Here is an easier version to read. Updated
Code: Select all
$sql = "INSERT INTO ".$prefix."_bbprivmsgs (privmsgs_type, privmsgs_subject, privmsgs_from_userid, privmsgs_to_userid, privmsgs_date ) VALUES ('1', '".$subject."', '$sending_user', '$recieving_user', ".$privmsgs_date.")";
if ( !$db->sql_query($sql, BEGIN_TRANSACTION) )
{
echo "Could not insert private message sent info";
}
$lastid = mysql_insert_id($sql);
All I am trying to do is get the last insert ID. This isn't working for some reason. (I am using phpNuke. If I change !$db->sql_query to !$db->mysql_query I get an error.)
Help please~

Posted: Sun Dec 11, 2005 6:38 pm
by Burrito
you're probably not including your database connection info on the page from which you're calling the sql_query method.
you really should get your insert id in the sql class anyway.
just write a new method to obtain your last inserted id and call it using the same object:
ex:
Posted: Sun Dec 11, 2005 7:30 pm
by davidprogramer
What do you mean? Write my own method? As in...I could use
$id = $db->getLatestId();
anywhere to get the last id??
How would that work?
Posted: Sun Dec 11, 2005 9:43 pm
by Burrito
well without seeing the class you're using for your queries, I can't really say EXACTLY how you'd need to do it.
I assume though that you have some method that utilizes your database resource (ie $result). So you could create a method that gets your inserted id.
something like this should work:
Code: Select all
function getLatestId()
{
$this->newId = mysql_insert_id();
return $this->newId;
}
echo $db->getLatestId();
Posted: Sun Dec 11, 2005 10:39 pm
by John Cartwright
Code: Select all
function getLatestId()
{
return mysql_insert_id();
}

Posted: Sun Dec 11, 2005 11:37 pm
by davidprogramer
Code: Select all
$privmsg_sent_id = $db->sql_nextid();
$message = "
Clan Name : $clan_name
Clan Tag : $clan_tag
Clan Status : $clan_status
Honor : $clan_honor
Ladder Name : $ladder_name
Clan Rank : $clan_rank
Clan Points : $clan_points
Clan Win % : $clan_winpercent %
Clan Wins/Losses : $clan_wins / $clan_losses
Clan Streak : $clan_streak
Clan Started on $clan_regdate
[url=http://www.aowars.com/modules.php?name=League&file=join_clan&op=accept&lid=$current_ladder&sid=$sending_user&pid=$recieving_playerid&cid=$clan_id&p=$privmsg_sent_id]<< ACCEPT >>[/url]
[url=http://www.aowars.com/modules.php?name=League&file=join_clan&op=reject&lid=$current_ladder&sid=$sending_user&pid=$recieving_playerid&cid=$clan_id&p=$privmsg_sent_id]<< REJECT >>[/url] ";
$message = "$message";
Got it. See where it has the next id thing. I just took the value it assigns to that and threw it in the link

. Such a noob mistake. Sorry.
Posted: Sun Dec 11, 2005 11:51 pm
by John Cartwright
fyi, no point on assigning a variable to itself
Might want to remove that line
Posted: Mon Dec 12, 2005 12:28 am
by davidprogramer
lol yeah. Thanks. Didn't even see it.
