help with MYSQL

dusean

New Member
hey guys ,
I installed sucessfully my torrent add on ..so thought to SUM all USERS completed torrrents and show in userstats ...but I can´t show it

if I put this code
$completes = $db->query_read("SELECT SUM(completed) AS com FROM ".TABLE_PREFIX."attachment WHERE userid = '".$userinfo['userid']." ' ");
while ($row = $db->fetch_array ($completes))
{
$completed = $row["com"];
}

returns nothing.

but if I put this code where I confirm that he read & sum userid 1´s completed torrent then I can see the total completions .

$completes = $db->query_read("SELECT SUM(completed) AS com FROM ".TABLE_PREFIX."attachment WHERE userid = 1");
while ($row = $db->fetch_array ($completes))
{
$completed = $row["com"];
}

can anyone please help me with showing completed torrents for each and every user
 

bluescorpion

New Member
I think you might need to use a more explicit variable in the query. For example:


$completes = $db->query_read("SELECT SUM(completed) AS com FROM ".TABLE_PREFIX."attachment WHERE userid = '$vbulletin->$userinfo['userid']' ");
 

dusean

New Member
No dude it´s not working gives me error
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /showthread.php on line 958
 

dusean

New Member
Guru said:
Try this

PHP:
$completes = $db->query_read("SELECT SUM(completed) AS com FROM ".TABLE_PREFIX."attachment WHERE userid = ". $vbulletin->$userinfo['userid'] );

query looks like above but I am unable to insert the value in showthread.php
 
Top