Creating a simple points system plugin. Need Total uploads variable. Creating a simple points system plugin. Need Total uploads variable.
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

Creating a simple points system plugin. Need Total uploads variable.

Started by Tasemu, October 14, 2010, 08:49:49 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Tasemu

Gday mates.

I am running a coppermine gallery which is bridged to mybb. Basically its used for members to upload renders to. I was hoping to code a simple and non flashy plugin that will assign points based on 2 variables that are added together (posts on the forum + images uploaded) and will post the total points to a page that has a table of every member.

So basically it is a simple points system for each member that does images uploaded + Posts made.

What i was hoping to get help with is a way to get the value of the total images uploaded that is available in the users gallery profile so i can use it in the script.

Sorry if its a simple and stupid question but im hoping to cut time in the production because its needed quite soon.

Thanks in advance and peace out. ^^

Αndré

global $CONFIG;
$user_id = 1234; // here you need to specify the user id
$pictures_count = mysql_result(cpg_db_query("SELECT COUNT(*) FROM {$CONFIG['TABLE_PICTURES']} WHERE owner_id = $user_id"), 0);


Alternatively you can use a query like
SELECT owner_id, COUNT(*) FROM {$CONFIG['TABLE_PICTURES']} GROUP BY owner_id

Tasemu

Cheers mate. I still get a problem which ill outline now.

P.S. I have managed to get the username and postcount from the mybb database and post them into a table.

When trying to do the same with the coppermine database i use the following code:


$con2 = mysql_connect("localhost","username","password");
if (!$con2)
{
die('Could not connect to cpg: ' . mysql_error());
}
echo "connected to gallery users";

mysql_select_db("tasemu_cpg");

$result2 = mysql_query("SELECT * FROM {$CONFIG['TABLE_PICTURES']}");

while($row2 = mysql_fetch_array($result2))
  {
  echo "<tr>";
  echo "<td>" . $row2['owner_id'] . "<td>";
  echo "<td>" . $row2['COUNT'] . "</td>";
  echo "</tr>";
  }
echo "</table>";

mysql_close($con2);



When i run the code i receive the following error for this code.

Error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/tasemu/public_html/forum/inc/mangarenderspoints/mangarenderspoints.php on line 59

Tasemu

Sry bout the double post but i couldnt find how to edit the post and thought this info will be useful:

while($row2 = mysql_fetch_array($result2)) <----- This is line 59 in the error haha. ^^

Αndré

If you run your script out of Coppermine's scope, you have to replace {$CONFIG['TABLE_PICTURES']} with your picture table name. In that case your question is not related to Coppermine, but basic SQL knowledge.

Tasemu

Haha yeah, cheers mate. I realised that earlier but wasnt brave enough to triple post haha. ^^

Joachim Müller

[ot]
This thread doesn't belong into this board. Who moved it here in the first place? Stop using the "General Discussion" board, it's dead as a dodo and should remain that way: dead.
[/ot]

Αndré

I moved it, as I thought it was the best place for this topic because it's not really related to Coppermine support. It was started in the cpg1.5.x plugin support board.

Joachim Müller