FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum » How To » th_inc_view_count() (Only increments if user is logged in)
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: th_inc_view_count() [message #162583 is a reply to message #162582] Sat, 12 June 2010 14:52 Go to previous messageGo to previous message
art is currently offline  art   
Messages: 35
Registered: June 2009
Karma:
Member
That's kind of my point. It's weird, isn't it? Viewers that aren't logged in cannot update the database for some reason.

I put this in th.inc.t:

function th_inc_view_count($id)
{
q('UPDATE {SQL_TABLE_PREFIX}thread SET views=views+1 WHERE id='.$id);
$result = q_singleval('SELECT views from {SQL_TABLE_PREFIX}thread where id='.$id);
print("<br>count=$result");
}

And I could see that the update simply doesn't work unless the user is logged in on the computer. I assume it's permission problems, or something in the fud_sql_lnk connection and possibly the variables set in GLOBALS preventing writes if the user isn't logged in. But I thought I'd ask before looking further.

I tried this also, with no success:

function th_inc_view_count($id)
{
$query = 'UPDATE {SQL_TABLE_PREFIX}thread SET views=views+1 WHERE id='.$id;
$result = mysql_query($query, fud_sql_lnk) or die (fud_sql_error_handler($query, mysql_error(fud_sql_lnk), mysql_errno(fud_sql_lnk), get_version()));
$result = q_singleval('SELECT views from {SQL_TABLE_PREFIX}thread where id='.$id);
print("<br>count=$result");
}

I did that thinking it may have been in the "q" function, but realized that this second form was essentially the same thing. That's what makes me think it is in the fud_sql_lnk connection perhaps.

Any other ideas?
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message icon6.gif
Previous Topic: Merging forums
Next Topic: Cookie domain
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Wed Nov 27 10:50:13 GMT 2024

Total time taken to generate the page: 0.04955 seconds