TinyPortal

Development => Block Codes => Topic started by: Inny on May 06, 2009, 11:54:41 AM

Title: [Block] EQDKP Recent Drops
Post by: Inny on May 06, 2009, 11:54:41 AM
As per requested this is the code i came up with, only decorative elements left.


$db_host = 'XXXX';
$db_user = 'XXXX';
$db_pass = 'XXXX';
$db_table = 'XXXX';

// edit variables above to your site's requirements

mysql_connect ($db_host, $db_user, $db_pass);
mysql_select_db ($db_table);
     
// Get latest items from each dkp pool
$dkp_tables = array('eqdkp');  // Your prefix may be different of course

$items = array();
print "<table border=0 class=text cellspacing=0 cellpadding=0 color=555652 face=Verdana>";
foreach ($dkp_tables as $table) {
   $result = mysql_query("SELECT item_ctrt_wowitemid, item_name, item_buyer, raid_date
                     FROM eqdkp_items AS i
                     INNER JOIN eqdkp_raids AS r ON i.raid_id=r.raid_id
                     ORDER BY raid_date DESC LIMIT 7") or die(mysql_error());

   while ($row = mysql_fetch_array($result))
   {
      //$row['dkpsite'] = $table;
      //$items[] = $row;
     $time = $row['raid_date'];
     print "<tr><td>Item: </td>
     <td><a href='http://www.wowhead.com/?item=" . $row['item_ctrt_wowitemid'] . "'>" . $row['item_name'] . "</a></td></tr>   
     <tr><td>Buyer: </td>
     <td>" . $row['item_buyer'] ."
     </td></tr>";
   }
}
print "</table>";


You need to have wowhead tooltips in your site it order to give you item tooltips. Installation of them can be found here (http://www.tinyportal.net/index.php/topic,29447.msg235454/topicseen.html#new).
Title: Re: EQDKP Recent Drops
Post by: JPDeni on May 06, 2009, 04:29:45 PM
Quoteonly issue is that it gives "Database not selected" error

The way to avoid problems is to put your tables into the same database as SMF. That way you don't have to worry about any database stuff at all and you can just use SMF's db_query function.
Title: Re: EQDKP Recent Drops
Post by: Inny on May 06, 2009, 05:11:40 PM
Yeah i dont really like running other things in the SMF database but yeah life would be so much easier :P

I fixed the code a bit, believe it or not i did it on my own!  ^-^

Just need to modify it a bit more to give wowhead tooltips now  :buck2:
Title: Re: EQDKP Recent Drops
Post by: Ianedres on May 06, 2009, 05:30:24 PM
I removed the database access information that was in the top of your code for security purposes.

You may wish to look at creating a sub-directory for including a second script that contains the database information; then you use the 'require_once' statement to get the variables into the above script.

Just a bit more protection against prying eyes... ;)
Title: Re: EQDKP Recent Drops
Post by: Inny on May 06, 2009, 06:45:10 PM
Quote from: Ianedres on May 06, 2009, 05:30:24 PM
I removed the database access information that was in the top of your code for security purposes.

You may wish to look at creating a sub-directory for including a second script that contains the database information; then you use the 'require_once' statement to get the variables into the above script.

Just a bit more protection against prying eyes... ;)

copy pasting hurts :( Thanks
Title: Re: EQDKP Recent Drops
Post by: Inny on May 07, 2009, 08:35:12 AM
Added in the code support for wowhead tooltips. Need some minor improvements on how the table looks which i will do in the following days.
Title: Re: EQDKP Recent Drops
Post by: maviel on May 07, 2009, 10:31:33 PM
is it possible to make bb codes work with this?
Title: Re: EQDKP Recent Drops
Post by: Inny on May 07, 2009, 10:37:56 PM
you mean [item][/item]?
Title: Re: EQDKP Recent Drops
Post by: maviel on May 07, 2009, 11:12:37 PM
Quote from: Inny on May 07, 2009, 10:37:56 PM
you mean [item][/item]?

yea
Title: Re: EQDKP Recent Drops
Post by: Inny on May 07, 2009, 11:23:12 PM
Try:

$db_host = 'XXXX';
$db_user = 'XXXX';
$db_pass = 'XXXX';
$db_table = 'XXXX';

// edit variables above to your site's requirements

mysql_connect ($db_host, $db_user, $db_pass);
mysql_select_db ($db_table);
     
// Get latest items from each dkp pool
$dkp_tables = array('eqdkp');  // Your prefix may be different of course

$items = array();
print "<table border=0 class=text cellspacing=0 cellpadding=0 color=555652 face=Verdana>";
foreach ($dkp_tables as $table) {
   $result = mysql_query("SELECT item_ctrt_wowitemid, item_name, item_buyer, raid_date
                     FROM eqdkp_items AS i
                     INNER JOIN eqdkp_raids AS r ON i.raid_id=r.raid_id
                     ORDER BY raid_date DESC LIMIT 7") or die(mysql_error());

   while ($row = mysql_fetch_array($result))
   {
      //$row['dkpsite'] = $table;
      //$items[] = $row;
     $time = $row['raid_date'];
     print "<tr><td>Item: </td>
     <td>[item]" . $row['item_name'] . "[/item]</td></tr>   
     <tr><td>Buyer: </td>
     <td>" . $row['item_buyer'] ."
     </td></tr>";
   }
}
print "</table>";


Not sure if your script will get the item tags in the php block but it should I think.
Title: Re: [Block] EQDKP Recent Drops
Post by: maviel on May 07, 2009, 11:52:43 PM
it should yes but since i have the dkp on another database instead of my current one i need to "call" my dkp database for the loot but then i need to call my portal database for the bb code i think. i did try this code on my own before and did not work since i dont have the wowitem tooldip for the dkp.

Hmm i think eqdkp.com have a tooltip thingy to! going to check! :D
Title: Re: [Block] EQDKP Recent Drops
Post by: maviel on May 08, 2009, 06:29:03 AM
nope did not work, it shows like this:

Item:     [item]Metallic Loop of the Sufferer[/item]

EDIT: here is my code i am using now and i do not think i can use css and java like this :/  :idiot2:


$db_host = 'xxxx';
$db_user = 'xxxx';
$db_pass = 'xxxx';
$db_table = '_udkp';

// edit variables above to your site's requirements

mysql_connect ($db_host, $db_user, $db_pass);
mysql_select_db ($db_table);

$eqdkp_root_path = 'udkp/';
include_once($eqdkp_root_path . 'eqdkp_config_itemstats.php');                                             
include_once($eqdkp_root_path . '/itemstats/eqdkp_itemstats.php');
     
     // Get latest items from each dkp pool
$dkp_tables = array('eqdkp_');  // Your prefix may be different of course

$items = array();

echo '
<link REL=StyleSheet HREF="udkp/itemstats/templates/" TYPE="text/css" MEDIA=screen />
<script type="text/javascript" src="udkp/itemstats/overlib/"><!-- overLIB (c) Erik Bosrup --></script>
<table border=0 class=text cellspacing=0 cellpadding=0 color=555652 face=Verdana>
';
foreach ($dkp_tables as $table) {
   $result = mysql_query("SELECT item_name, item_buyer, raid_date
                     FROM eqdkp_items AS i
                     INNER JOIN eqdkp_raids AS r ON i.raid_id=r.raid_id
                     ORDER BY raid_date DESC LIMIT 7") or die(mysql_error());

   while ($row = mysql_fetch_array($result))
   {
      //$row['dkpsite'] = $table;
      //$items[] = $row;
     $time = $row['raid_date'];
     echo '<tr><td>Item: </td>
     <td>[item]'. $row['item_name'] .'[/item]</td></tr> 
     <tr><td>Buyer: </td>
     <td>' . $row['item_buyer'] .'
     </td></tr>';
   }
}
echo '</table>';


$db_host = 'xxxx';
$db_user = 'xxxx';
$db_pass = 'xxxx';
$db_table = '_portal';

mysql_connect ($db_host, $db_user, $db_pass);
mysql_select_db ($db_table);
     
Title: Re: [Block] EQDKP Recent Drops
Post by: Inny on May 08, 2009, 07:37:06 AM
Why use the ccs file and the script in the block?

That two should be already loaded from index.template
Title: Re: [Block] EQDKP Recent Drops
Post by: Inny on May 08, 2009, 07:55:47 AM
Seeing the installation of the itemstats you using, i think that mod lets say wont work with block because its looking for the tags in topic messages only.

Lets try to work this with an include, try the code below.


// Wowhead Tooltips
require_once(dirname(__FILE__) . '/../wowhead/parse.php');

$db_host = 'XXXX';
$db_user = 'XXXX';
$db_pass = 'XXXX';
$db_table = 'XXXX';

// edit variables above to your site's requirements

mysql_connect ($db_host, $db_user, $db_pass);
mysql_select_db ($db_table);
     
// Get latest items from each dkp pool
$dkp_tables = array('eqdkp');  // Your prefix may be different of course

$items = array();
print "<table border=0 class=text cellspacing=0 cellpadding=0 color=555652 face=Verdana>";
foreach ($dkp_tables as $table) {
   $result = mysql_query("SELECT item_ctrt_wowitemid, item_name, item_buyer, raid_date
                     FROM eqdkp_items AS i
                     INNER JOIN eqdkp_raids AS r ON i.raid_id=r.raid_id
                     ORDER BY raid_date DESC LIMIT 7") or die(mysql_error());

   while ($row = mysql_fetch_array($result))
   {
      //$row['dkpsite'] = $table;
      //$items[] = $row;
     $time = $row['raid_date'];
     print "<tr><td>Item: </td>
     <td>[item]" . $row['item_name'] . "[/item]</td></tr>   
     <tr><td>Buyer: </td>
     <td>" . $row['item_buyer'] ."
     </td></tr>";
   }
}
print "</table>";


In the first 2 lines of the code you will see:

// Wowhead Tooltips
require_once(dirname(__FILE__) . '/../wowhead/parse.php');


Change it with the correct directory with your wowhead script directory.
Title: Re: [Block] EQDKP Recent Drops
Post by: maviel on May 08, 2009, 09:11:49 AM
Quote from: Inny on May 08, 2009, 07:37:06 AM
Why use the ccs file and the script in the block?

That two should be already loaded from index.template

even if it is loaded from index.template does not mean it will load from the same database since i am "calling" my seperate dkp datarbase wich is only for dkp related stuff.  :D

and i cant find any file named "parse.php" mate... sorry for being an ass! and take your time but for the record it is real nice of you for helping me out.

Title: Re: [Block] EQDKP Recent Drops
Post by: Inny on May 08, 2009, 09:25:28 AM
The script you call and the css has nothing to do with the database.

You said you installed Itemstats modification, referring to this (http://www.tinyportal.net/index.php/topic,29447.msg235454.html#msg235454). Have you followed the installation steps for SMF?

If you are not having that mod what mod you have for the itemstats tooltips?
Title: Re: [Block] EQDKP Recent Drops
Post by: maviel on May 08, 2009, 05:33:22 PM
ok to make it simple....





Database 1Database 2
SMF Installation / TP Installation. All css related to this database is being readed from index.template right?DKP Installation / Tooltip for eqdkp. When switching to database 2 it is a whole different thing? since index.template is not here now i am reading from the root and using the css styles from my database 2 and index etc.. right? or am i wrong?
Title: Re: [Block] EQDKP Recent Drops
Post by: Inny on May 09, 2009, 09:10:57 AM
Quote from: maviel on May 08, 2009, 05:33:22 PM
DKP Installation / Tooltip for eqdkp. When switching to database 2 it is a whole different thing? since index.template is not here now i am reading from the root and using the css styles from my database 2 and index etc.. right? or am i wrong?

As it the block right now theres no any CSS related values to any of those, Tooltips scripts is using the script to get the css values as far as i know.

Major thing you need to tell me is if you get the tooltips right. Again CSS has nothing to do with the tooltips for now.
Title: Re: [Block] EQDKP Recent Drops
Post by: maviel on May 09, 2009, 10:01:14 AM
nope still have [item] issue... require_once(dirname(__FILE__) . '/../wowhead/parse.php'); i do not have any file named parse.php :(
Title: Re: [Block] EQDKP Recent Drops
Post by: Inny on May 09, 2009, 10:17:35 AM
Quote from: Inny on May 08, 2009, 09:25:28 AM
You said you installed Itemstats modification, referring to this (http://www.tinyportal.net/index.php/topic,29447.msg235454.html#msg235454). Have you followed the installation steps for SMF?

If you are not having that mod what mod you have for the itemstats tooltips?

Answer please :P
Title: Re: [Block] EQDKP Recent Drops
Post by: maviel on May 09, 2009, 06:44:29 PM
ooops yea my bad! :D still do not work added the line

// Wowhead Tooltips
require_once(dirname(__FILE__) . '/../wowhead/parse.php');


in the top of the script and still i have eg.

[item]Metallic Loop of the Sufferer[/item]
Title: Re: [Block] EQDKP Recent Drops
Post by: MrDuck on May 24, 2009, 03:43:49 PM
Hmm, i've just made one block for this purpose before checking this thread, it's on web where wowhead tooltip is running, so there's nothing to handle these as it's done automatically, and assumes eqdkp is in ./eqdkp folder relative to board index.
An example can be found at http://not-prepared.eu
Feel free to abuse and expand it in any way.

if (!ini_get('display_errors')) { // Debug part
    ini_set('display_errors', 1);
    //echo "PHP Display Errors Enabled<br />\n";
}

require "./eqdkp/config.php";

define("DBHOST", $dbhost);
define("DBNAME", $dbname);
define("DBUSER", $dbuser);
define("DBPASS", $dbpass);
define("ITEMS", 7);           //How many items will we list?

$link = mysql_connect(DBHOST, DBUSER, DBPASS);
if (!$link) {
    die('Could not connect to EQDKP database: ' . mysql_error());
}

$result = mysql_db_query(DBNAME, "SELECT
eqdkp_items.item_date AS date, eqdkp_items.item_buyer AS looter, eqdkp_items.game_itemid AS itemid, eqdkp_items.item_value AS cost,
item_cache.item_name AS name, item_cache.item_color AS  quality, item_cache.item_icon AS icon,
eqdkp_members.member_class_id AS class
FROM eqdkp_items, eqdkp_members, item_cache
WHERE eqdkp_items.game_itemid = item_cache.item_id
AND eqdkp_items.item_buyer = eqdkp_members.member_name
ORDER BY date DESC LIMIT " . ITEMS . "
;", $link);
// date, looter, itemid, cost, name, quality, icon, class

$i=0;
while($row = mysql_fetch_assoc($result)) {
  switch ($row['quality']) {    //item color
    case 'orangename':
      $q = "ff8000";
      break;
    case 'purplename':
      $q = "a335ee";
      break;
    default:
      $q = "000";
  }
  switch ($row['class']) {      //player class color
    case 7: //druid
      $c = "FF7C0A";
      break;
    case 10: //warlock
      $c = "9382C9";
      break;
    case 4: //hunter
      $c = "AAD372";
      break;
    case 12: //warrior
      $c = "C69B6D";
      break;
    case 13: //paladin
      $c = "F48CBA";
      break;
    case 11: //mage
      $c = "68CCEF";
      break;
    case 6: //priest
      $c = "AAAAAA";
      break;
    case 9: //shaman
      $c = "1A3CAA";
      break;
    case 2: //rogue
      $c = "FFF468";
      break;
    case 20: //deathknight
      $c = "C41F3B";
      break;
    default:
      $c = "000";
  }
  if ($i > 0)
    echo "<hr style=\"height: 1px; margin: 0px; border: none; background-color: " . $q . "; color: " . $q . "\" />";
  else $i++;
  echo "<img src=\"http://static.wowhead.com/images/icons/small/" . $row['icon'] . ".jpg\" style=\"vertical-align: middle; padding: 0 -2px 0 -2px;\" />";
  echo "<span style=\"color: #" . $c . "; vertical-align: middle; font-weight: bold;\">&nbsp;" . $row['looter'] . "</span>&nbsp;[" . $row['cost'] . "]<br />\n";
  echo "<a href=\"http://wowhead.com/?item=" . $row['itemid'] . "\" target=\"_blank\" style=\"color: #" . $q . "; text-decoration: none;\">";
  echo "[" . $row['name'] . "]</a>";
}

mysql_free_result($result);
mysql_close($link);

Title: Re: [Block] EQDKP Recent Drops
Post by: Inny on May 24, 2009, 03:53:27 PM
Seems better than mine, i will delete mine and put yours if you dont mind with you as an author of course.

Yours seems more complete and the styling from mine is missing and running out of time.
Title: Re: [Block] EQDKP Recent Drops
Post by: Inny on May 24, 2009, 04:39:56 PM
My block doesnt show any items, i will check what i might did wrong, only changed the path
Title: Re: [Block] EQDKP Recent Drops
Post by: MrDuck on May 24, 2009, 09:45:30 PM
Quote from: Inny on May 24, 2009, 04:39:56 PM
My block doesnt show any items, i will check what i might did wrong, only changed the path
Do you get any errors or something? Also, what version of dkp system are you using? I have EQDKP Plus here, I believe the database structure should be the same,but I'm not 100% sure. If the database has filled members, items and item_cache, there shouldn't be any problem.
Try adding if (!$result) {
    echo "DB Error, could not query the database\n";
    echo 'MySQL Error: ' . mysql_error();
    exit;
}
before the while {} to see if there's a problem with connecting to the database, but i believe it should be fine if the EQDKP is working and it connects fine (otherwise the mysql_connect() should say something already).
Title: Re: [Block] EQDKP Recent Drops
Post by: Inny on May 24, 2009, 11:02:36 PM
Im running EQDKP 1.3.2.

I will check the tables, totaly forgot to check it.

I dont get any errors, connecting seems fine since i dont get any errors, added the code you told me aswell and still block shows nothing.

In any case i will check the table structure.
Title: Re: [Block] EQDKP Recent Drops
Post by: Inny on May 26, 2009, 04:36:02 PM
Was checking my error log and seems i found 2 errors related to that:
1) mysql_free_result(): supplied argument is not a valid MySQL result resource
2) mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource
Title: Re: [Block] EQDKP Recent Drops
Post by: MrDuck on May 27, 2009, 09:27:28 AM
Quote from: Inny on May 26, 2009, 04:36:02 PM
Was checking my error log and seems i found 2 errors related to that:
1) mysql_free_result(): supplied argument is not a valid MySQL result resource
2) mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource
Well it means there's probably some problem with executing the query, however i believe the bit of code i posted before should tell that. Could you try just adding "echo mysql_error();" after the query?

(BTW, pretty nice web, wtb yer design :P)

EDIT: actually, try changing it to the following (after you change your patch to config again), updated a few minor things there and made it (hopefully) easier to debug:
if (!ini_get('display_errors')) { // Debug part
    ini_set('display_errors', 1);
    //echo "PHP Display Errors Enabled<br />\n";
}

require "./eqdkp/config.php";

define("DBHOST", $dbhost);
define("DBNAME", $dbname);
define("DBUSER", $dbuser);
define("DBPASS", $dbpass);
define("ITEMS", 7);           //How many items will we list?

$link = mysql_connect(DBHOST, DBUSER, DBPASS);
if (!$link) {
    die('Could not connect to EQDKP database: ' . mysql_error());
}

$sql = "SELECT
eqdkp_items.item_date AS date, eqdkp_items.item_buyer AS looter, eqdkp_items.game_itemid AS itemid, eqdkp_items.item_value AS cost,
item_cache.item_name AS name, item_cache.item_color AS  quality, item_cache.item_icon AS icon,
eqdkp_members.member_class_id AS class
FROM eqdkp_items, eqdkp_members, item_cache
WHERE eqdkp_items.game_itemid = item_cache.item_id
AND eqdkp_items.item_buyer = eqdkp_members.member_name
ORDER BY date DESC LIMIT " . ITEMS . "
;";
// date, looter, itemid, cost, name, quality, icon, class

$result = mysql_db_query(DBNAME, $sql, $link) or die("Error in the MySQL query: <br />".$sql."<br /><br /><br />".mysql_error());

$i=0;
while($row = mysql_fetch_assoc($result)) {
  switch ($row['quality']) {    //item color
    case 'orangename':
      $q = "ff8000";
      break;
    case 'purplename':
      $q = "a335ee";
      break;
    default:
      $q = "000";
  }
  switch ($row['class']) {      //player class color
    case 7: //druid FF7C0A
      $c = "FF7C0A";
      break;
    case 10: //warlock 9382C9
      $c = "9382C9";
      break;
    case 4: //hunter AAD372
      $c = "AAD372";
      break;
    case 12: //warrior C69B6D
      $c = "C69B6D";
      break;
    case 13: //paladin F48CBA
      $c = "E47CAA";
      break;
    case 11: //mage 68CCEF
      $c = "68CCEF";
      break;
    case 6: //priest AAAAAA
      $c = "AAAAAA";
      break;
    case 9: //shaman 1A3CAA
      $c = "1A3CAA";
      break;
    case 2: //rogue FFF468
      $c = "DFD418";
      break;
    case 20: //deathknight C41F3B
      $c = "C41F3B";
      break;
    default:
      $c = "000";
  }
  if ($i > 0)
    echo "<hr style=\"height: 1px; margin: 0px; border: none; background-color: " . $q . "; color: " . $q . "\" />";
  else $i++;
  echo "<img src=\"http://static.wowhead.com/images/icons/small/" . $row['icon'] . ".jpg\" style=\"vertical-align: middle; padding: 0 -2px 0 -2px;\" />";
  echo "<span style=\"color: #" . $c . "; vertical-align: middle; font-weight: bold;\">&nbsp;" . utf8_encode($row['looter']) . "</span>&nbsp;[" . $row['cost'] . "]<br />\n";
  echo "<a href=\"http://wowhead.com/?item=" . $row['itemid'] . "\" target=\"_blank\" style=\"color: #" . $q . "; text-decoration: none;\">";
  echo "[" . $row['name'] . "]</a>";
}

mysql_free_result($result);
mysql_close($link);


The easiest and fastest way to find out, imo, is just creating a separate php file with this code (and added <? at start, ?> at the end ofc), and running it in there, it'll give you all errors without having to check error logs and such. (as on http://not-prepared.eu/test.php )
Title: Re: [Block] EQDKP Recent Drops
Post by: Inny on May 27, 2009, 12:13:23 PM
Heres the error now:


Error in the MySQL query:
SELECT eqdkp_items.item_date AS date, eqdkp_items.item_buyer AS looter, eqdkp_items.game_itemid AS itemid, eqdkp_items.item_value AS cost, item_cache.item_name AS name, item_cache.item_color AS quality, item_cache.item_icon AS icon, eqdkp_members.member_class_id AS class FROM eqdkp_items, eqdkp_members, item_cache WHERE eqdkp_items.game_itemid = item_cache.item_id AND eqdkp_items.item_buyer = eqdkp_members.member_name ORDER BY date DESC LIMIT 7 ;


Table '$$$_$$$.item_cache' doesn't exist
Title: Re: [Block] EQDKP Recent Drops
Post by: MrDuck on May 27, 2009, 02:40:36 PM
Quote from: Inny on May 27, 2009, 12:13:23 PM
Table '$$$_$$$.item_cache' doesn't exist
I see,so you don't have an 'item_cache' table in the database where rest of eqdkp is? I assume the $$$ is your database name,right? Sounds like there's no item_cache in basic eqdkp, i'm not sure about it though. I'll try to get eqdkp running here to see its DB structure and eventually try to tweak it to make the script compatible with both eqdkp and eqdkp+.
Title: Re: [Block] EQDKP Recent Drops
Post by: Inny on May 27, 2009, 03:17:31 PM
yeha $$$ is the name.

Item_cache table is created when you have Itemstats.

I will check the code in my T7 database, intentionally left Itemstats on T8 behind.

EDIT:

On my database with itemstats i get this error:
Table './&&&/item_cache' is marked as crashed and should be repaired

So i guess itemstats tables are installed differently on EQDKP plus, while they dont exist in normal un-modded installations of EQDKP.

If you make it work for normal EQDKP installations will be perfect :P
Title: Re: [Block] EQDKP Recent Drops
Post by: MrDuck on May 27, 2009, 03:33:39 PM
I see,well itemstats are pretty much needed to get the item name and such, or else i'd basically have to write them anyway. The name could be dynamically obtained from wowhead i guess, but it may require unneccessary load on wowhead servers and eventually be pretty slow, though i didn't play with that at all yet.

However, the error you posted points more likely to some database corruption, did you try the repair table thing in phpmyadmin?
Title: Re: [Block] EQDKP Recent Drops
Post by: Inny on May 27, 2009, 04:15:29 PM
on to the next error after fixing.

Error:
Unknown column 'eqdkp_items.game_itemid' in 'field list'

Checked the item_cache, item id is under item_id and not game_itemid

In eqdkp_items the item id is located under item_ctrt_wowitemid (for me at least)
Title: Re: [Block] EQDKP Recent Drops
Post by: MrDuck on May 27, 2009, 09:02:45 PM
Quote from: Inny on May 27, 2009, 04:15:29 PM
on to the next error after fixing.

Error:
Unknown column 'eqdkp_items.game_itemid' in 'field list'

Checked the item_cache, item id is under item_id and not game_itemid

In eqdkp_items the item id is located under item_ctrt_wowitemid (for me at least)
I see, well i'm using the game_itemid (that's not the item_cache table btw, it's in eqdkp_items) 'cause i've noticed i have 2 items in database with empty item_ctrt_wowitemid, while these with game_itemid are all 100% correct. I'll still try to set up the basic eqdkp and see if there are any differences so i could determine which dkp system is running and automatically pick the correct table structure, or i'll just make it configurable. I'll try to have it done today, lets see how it works out, i'll let you know asap.
Title: Re: [Block] EQDKP Recent Drops
Post by: MrDuck on May 27, 2009, 09:36:46 PM
Ok,try this. The second query should work in both versions (honestly i didn't bother installing itemstats in the simple eqdkp, so it's untested there, but seeing the DB structure,it should work), first seems more solid to me (i prefer matching int over a string, even though it's probably not needed). So, i think it's clear, in the initial section, set PLUS definition to 0 for EQDKP normal, 1 for EQDKP+, 0 works in both cases but i don't like it that much :P Report back how it works or what error it gives, if any, please :-) Thanks for feedback btw :P


if (!ini_get('display_errors')) { // Debug part
    ini_set('display_errors', 1);
    //echo "PHP Display Errors Enabled<br />\n";
}

require "./eqdkp/config.php";

define("DBHOST", $dbhost);
define("DBNAME", $dbname);
define("DBUSER", $dbuser);
define("DBPASS", $dbpass);
define("ITEMS", 7);           //How many items will we list?
define("PLUS" , 0);            //Is it EQDKP or EQDKP+? (1 for plus, 0 for the basic version)
$link = mysql_connect(DBHOST, DBUSER, DBPASS);
if (!$link) {
    die('Could not connect to EQDKP database: ' . mysql_error());
}

if(PLUS) {
  $sql = "SELECT
  eqdkp_items.item_date AS date, eqdkp_items.item_buyer AS looter, eqdkp_items.game_itemid AS itemid, eqdkp_items.item_value AS cost,
  item_cache.item_name AS name, item_cache.item_color AS  quality, item_cache.item_icon AS icon,
  eqdkp_members.member_class_id AS class
  FROM eqdkp_items, eqdkp_members, item_cache
  WHERE eqdkp_items.game_itemid = item_cache.item_id
  AND eqdkp_items.item_buyer = eqdkp_members.member_name
  ORDER BY date DESC LIMIT " . ITEMS . "
  ;";
}else{
  $sql = "SELECT
  eqdkp_items.item_date AS date, eqdkp_items.item_buyer AS looter, eqdkp_items.game_itemid AS itemid, eqdkp_items.item_value AS cost,
  item_cache.item_name AS name, item_cache.item_color AS  quality, item_cache.item_icon AS icon,
  eqdkp_members.member_class_id AS class
  FROM eqdkp_items, eqdkp_members, item_cache
  WHERE eqdkp_items.item_name = item_cache.item_name
  AND eqdkp_items.item_buyer = eqdkp_members.member_name
  ORDER BY date DESC LIMIT " . ITEMS . "
  ;";

}
// date, looter, itemid, cost, name, quality, icon, class

$result = mysql_db_query(DBNAME, $sql, $link) or die("Error in the MySQL query: <br />".$sql."<br /><br /><br />".mysql_error());

$i=0;
while($row = mysql_fetch_assoc($result)) {
  switch ($row['quality']) {    //item color
    case 'orangename':
      $q = "ff8000";
      break;
    case 'purplename':
      $q = "a335ee";
      break;
    default:
      $q = "000";
  }
  switch ($row['class']) {      //player class color
    case 7: //druid FF7C0A
      $c = "FF7C0A";
      break;
    case 10: //warlock 9382C9
      $c = "9382C9";
      break;
    case 4: //hunter AAD372
      $c = "AAD372";
      break;
    case 12: //warrior C69B6D
      $c = "C69B6D";
      break;
    case 13: //paladin F48CBA
      $c = "E47CAA";
      break;
    case 11: //mage 68CCEF
      $c = "68CCEF";
      break;
    case 6: //priest AAAAAA
      $c = "AAAAAA";
      break;
    case 9: //shaman 1A3CAA
      $c = "1A3CAA";
      break;
    case 2: //rogue FFF468
      $c = "DFD418";
      break;
    case 20: //deathknight C41F3B
      $c = "C41F3B";
      break;
    default:
      $c = "000";
  }
  if ($i > 0)
    echo "<hr style=\"height: 1px; margin: 0px; border: none; background-color: " . $q . "; color: " . $q . "\" />";
  else $i++;
  echo "<img src=\"http://static.wowhead.com/images/icons/small/" . $row['icon'] . ".jpg\" style=\"vertical-align: middle; padding: 0 -2px 0 -2px;\" />";
  echo "<span style=\"color: #" . $c . "; vertical-align: middle; font-weight: bold;\">&nbsp;" . utf8_encode($row['looter']) . "</span>&nbsp;[" . $row['cost'] . "]<br />\n";
  echo "<a href=\"http://wowhead.com/?item=" . $row['itemid'] . "\" target=\"_blank\" style=\"color: #" . $q . "; text-decoration: none;\">";
  echo "[" . $row['name'] . "]</a>";
}

mysql_free_result($result);
mysql_close($link);

Title: Re: [Block] EQDKP Recent Drops
Post by: Inny on May 27, 2009, 10:30:38 PM
You have an item_cache table in frech EQDKP Install? What version you installed?

Now getting:
Table '$$$_$$$.item_cache' doesn't exist
Title: Re: [Block] EQDKP Recent Drops
Post by: MrDuck on May 28, 2009, 10:02:07 PM
Quote from: Inny on May 27, 2009, 10:30:38 PM
You have an item_cache table in frech EQDKP Install? What version you installed?

Now getting:
Table '$$$_$$$.item_cache' doesn't exist
Well no not in fresh install, i thought that itemstats thing adds the table? thinking about it now, it may not be even needed, but i'm not sure if there's any other way to figure out the item quality without itemstats.


EDIT: on a side note, that item_cache is in fresh install of EQDKP+, but i think these itemstats for basic EQDKP are pretty much needed for a script like this to work. Could be done without, but some similar thing to itemstats would've been needed to be implemented or something like that to store information about these items.
Title: Re: [Block] EQDKP Recent Drops
Post by: Tyrock on June 02, 2009, 02:13:48 PM
great work..!!!!  :up:

but i have an Error, can someone help?


Parse error: syntax error, unexpected '&' in /mnt/web3/41/72/52098672/htdocs/Sources/Load.php(1745) : eval()'d code(48) : eval()'d code on line 6


SMF v1.1.9
TinyPortal v1.0 beta 3

plx plx plx :)
Title: Re: [Block] EQDKP Recent Drops
Post by: MrDuck on June 03, 2009, 11:01:10 PM
Quote from: Tyrock on June 02, 2009, 02:13:48 PM
great work..!!!!  :up:

but i have an Error, can someone help?


Parse error: syntax error, unexpected '&' in /mnt/web3/41/72/52098672/htdocs/Sources/Load.php(1745) : eval()'d code(48) : eval()'d code on line 6


SMF v1.1.9
TinyPortal v1.0 beta 3

plx plx plx :)
Well that seems quite weird, looking at the Load.php, but i can't seem to find any clue about what's going on there, though i have some modified version of the file (through mods ya know), so could you send me your line 1745 of Load.php? I don't think it'll help me much, but at least something to start with.
Title: Re: [Block] EQDKP Recent Drops
Post by: xthelocustx on July 22, 2009, 01:40:26 PM
Quote from: MrDuck on June 03, 2009, 11:01:10 PM
Quote from: Tyrock on June 02, 2009, 02:13:48 PM
great work..!!!!  :up:

but i have an Error, can someone help?


Parse error: syntax error, unexpected '&' in /mnt/web3/41/72/52098672/htdocs/Sources/Load.php(1745) : eval()'d code(48) : eval()'d code on line 6


SMF v1.1.9
TinyPortal v1.0 beta 3

plx plx plx :)
Well that seems quite weird, looking at the Load.php, but i can't seem to find any clue about what's going on there, though i have some modified version of the file (through mods ya know), so could you send me your line 1745 of Load.php? I don't think it'll help me much, but at least something to start with.


I get this same exact error.

Line:1745
$file_found = file_exists($filename) && eval('?' . '>' . rtrim(file_get_contents($filename))) !== false;
Title: Re: [Block] EQDKP Recent Drops
Post by: Kahless on August 16, 2009, 05:51:10 PM
I hope you can help me with the problem i have when i install this block, the block works etc on all browsers but ie7. i have about 15 off my raiders who use ie7 and they can't acces the page when i got this block enabled. When i disable it they can access the website fine.

they don't get any errors, they just get the notice: page could not be displayed

Any ideas?

ps i used the code for the block thats posted last by MrDuck

using smf 1.1.10 and tp 0.983

website: www.legend-reborn.com