MyBB Community Forums

Full Version: Code to insert post count into mysql
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I not sure if this the place to ask this question so forgive me if it not.

I have created another mysql table called mybb_track. What I need to know is what is the code for inserting the postnum (post count) into it.

if($mybb->user['uid']==0) 
{
                     
$tm=time();
$ref=$HTTP_REFERER;
$agent=$HTTP_USER_AGENT;
$ip=hexdec(substr(md5($_SERVER['REMOTE_ADDR']), 0, 6));
$db->query("INSERT INTO mybb_track(tm, ref, agent, ip, postnum) VALUES ('$tm','$ref','$agent','$ip','$postnum')");

}

Everything works great except postnum.
Thanks
It looks like you are referring to a user id of 0; ie a none existent user. The postnum is part of the user table, so that variable cannot be accessed if it isn't a user.
(2014-05-23, 06:04 PM)Leefish Wrote: [ -> ]It looks like you are referring to a user id of 0; ie a none existent user. The postnum is part of the user table, so that variable cannot be accessed if it isn't a user.

OK, this is for tracking guest only.

Thanks,

One more question. Is there an easy way to count how many posts a guest makes by their ip address until thier IP changes?