TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,963
  • Latest: BiZaJe
Stats
  • Total Posts: 195,913
  • Total Topics: 21,308
  • Online today: 884
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 413
  • Total: 413

[Block] EQDKP Recent Drops

Started by Inny, May 06, 2009, 11:54:41 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

maviel

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]

MrDuck

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);


Inny

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.

Inny

My block doesnt show any items, i will check what i might did wrong, only changed the path

MrDuck

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).

Inny

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.

Inny

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

MrDuck

#27
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 )

Inny

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

MrDuck

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+.

This website is proudly hosted on Crocweb Cloud Website Hosting.