Bravo List

Bravo List (http://www.bvlist.com/index.php)
-   TBDev (http://www.bvlist.com/forumdisplay.php?f=20)
-   -   Count (http://www.bvlist.com/showthread.php?t=7112)

FTWR 21st October 2011 23:36

Count
 
I need a function to cleanup.php file to count how much uploaded torrents and forum posts have every user.

Quote:

$uploaded_torrents = mysql_query("SELECT COUNT(*) FROM torrents WHERE owner=" . $user["id"] ."") or print(mysql_error());
Quote:

$forum_posts = mysql_query("SELECT COUNT(*) FROM posts WHERE userid=" . $user['id']) or sqlerr();
Where is the mistake because the lines don't work.

P.S: I use Tbdev 2009!

joeroberts 22nd October 2011 08:24

try it like so
PHP Code:

$uploaded_torrents mysql_query("SELECT COUNT(id) FROM torrents WHERE owner=" $user["id"] ."") or print(mysql_error()); 

PHP Code:

$forum_posts mysql_query("SELECT COUNT(id) FROM posts WHERE userid=" $user['id']) or sqlerr(); 

mysql don't like to count wild cards

FTWR 22nd October 2011 15:17

Don't work!

Quote:

Notice: Undefined variable: user in /home/admin/***/include/cleanup.php on line 153
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
Notice: Undefined variable: user in /home/admin/***/include/cleanup.php on line 154
MySQL Error

There appears to be an error with the database.
You can try to refresh the page by clicking here.

Error Returned
Quote:

SQL error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
SQL error code: 1064
Date: Saturday 22nd of October 2011 04:17:27 PM



joeroberts 22nd October 2011 15:53

the query works you just gave me the wrong variable you need to fix $user['id']

Quote:

Notice: Undefined variable: user in /home/admin/***/include/cleanup.php on line 153

FTWR 23rd October 2011 09:08

The code is from userdetails.php. Do you think it work with that:

Quote:

$id = 0 + $_GET["id"];

joeroberts 23rd October 2011 09:19

I would need to see the complete code to see what is going on and what your trying to do.

FTWR 23rd October 2011 11:34

Quote:

//Uploaded Torrents
$res3 = mysql_query("SELECT COUNT(*) FROM torrents WHERE owner=" . $user["id"] ."") or print(mysql_error());
$row2 = mysql_fetch_row($res3);
$uploaded_torrents = $row2[0];
//Forum Posts
$res = mysql_query("SELECT COUNT(*) FROM posts WHERE userid=" . $user['id']) or sqlerr();
$arr3 = mysql_fetch_row($res);
$forumposts = $arr3[0];
.....

joeroberts 23rd October 2011 15:50

are you trying to update for every user?
where is the $user["id"] part suppose to be coming from?
what are you doing with the information after you get it?

FTWR 23rd October 2011 19:37

Yes, for every user. With the information I will use it to promote at a new class (at a number of torrents).


All times are GMT +2. The time now is 21:26.

Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions Inc.