I don't know if this is the right place for this, but I coded the following inspired from the 'Your DKP' Joomla block. I recently tore down Joomla, but wanted to keep the block. I had to do a complete recode, but the following works on my installation.
This assumes that EQDKP is in the same database as your SMF/TP forums. It also assumes that the currently logged on user's logon name is the same as their character's name that appears on the DKP Boards. For example, Tigertamp is a username and Tigertamp is a character on the EQDKP board.
Put the following in a phpbox:
global $db_prefix, $context, $user_info, $ID_MEMBER;
$EQPrefix = "eqdkp_";
echo '<center>';
$sql1 = "SELECT * FROM {$EQPrefix}members WHERE member_name='" . $context['user']['name'] ."'";
if ($context['user']['is_logged']){
$request = db_query($sql1, __FILE__, __LINE__);
$row = mysql_fetch_assoc($request);
if (empty($row['member_name'])){
echo 'You have no DKP. Join a run!<br>';
}
else
{
$totaldkp=$row['member_earned'] - $row['member_spent'] + $row['member_adjustment'];
echo 'You have '. $totaldkp .' DKP points. <br>';
}
};
if (!$context['user']['is_logged']){
echo 'Please login or register to see your DKP.';
}
echo '</center>';
would love to see a version that has the database not in the TP one
anyone know how to call another database on the server using this code?
You would have to implement the mysql_connect and mysql_select_db functions ahead of the queries... that would allow the code to connect to another server (outside of TP) and then use the database tables for EverQuest.
Provided the table structure was the same, the rest of the code would work from there and the code should be able to access the information.
I don't have EQ, but this is the general scope of what would be needed.
ok, i am new to php and i checked php.net... code as u described would look like this?
mysql_connect (DB_HOST, DB_USER, DB_PASSWORD);
mysql_select_db (DB_NAME);
and direct after put the code:
global $db_prefix, $context, $user_info, $ID_MEMBER;
$EQPrefix = "eqdkp_";
echo '<center>';
$sql1 = "SELECT * FROM {$EQPrefix}members WHERE member_name='" . $context['user']['name'] ."'";
if ($context['user']['is_logged']){
$request = db_query($sql1, __FILE__, __LINE__);
$row = mysql_fetch_assoc($request);
if (empty($row['member_name'])){
echo 'You have no DKP. Join a run!<br>';
}
else
{
$totaldkp=$row['member_earned'] - $row['member_spent'] + $row['member_adjustment'];
echo 'You have '. $totaldkp .' DKP points. <br>';
}
};
if (!$context['user']['is_logged']){
echo 'Please login or register to see your DKP.';
}
echo '</center>';
EDIT: it now reads from my 2nd database which means that the site thinks it is on my "portal" database. Anyone know how to fix so i can make this code call back to the other database in the end of the 2nd code.
You could put those two functions at the top of the script; you will need to replace the constants (in all-caps) with your site's info for the host, user name to access the server, and accompanying password for the mysql_connect.
Then replace the DB_NAME with your EQ database that is storing your info.
A simple change of db_query (SMF's version) to a standard mysql_query call is needed; I also added LIMIT 1 at the end of the query to restrict its results to just one.
Try this... may need refining, but should be close...
global $db_prefix, $context, $user_info, $ID_MEMBER;
$EQPrefix = "eqdkp_";
$db_host = 'your mysql host name';
$db_user = 'your database user name';
$db_pass = 'your database password';
$db_table = 'database name to access';
// edit variables above to your site's requirements
mysql_connect ($db_host, $db_user, $db_pass);
mysql_select_db ($db_table);
echo '<center>';
$sql1 = "SELECT * FROM {$EQPrefix}members WHERE member_name='" . $context['user']['name'] ."' LIMIT 1";
if ($context['user']['is_logged']){
$request = mysql_query($sql1);
$row = mysql_fetch_assoc($request);
if (empty($row['member_name'])){
echo 'You have no DKP. Join a run!<br>';
}
else
{
$totaldkp=$row['member_earned'] - $row['member_spent'] + $row['member_adjustment'];
echo 'You have '. $totaldkp .' DKP points. <br>';
}
};
if (!$context['user']['is_logged']){
echo 'Please login or register to see your DKP.';
}
echo '</center>';
this did not work at all i did get a blank page when putting this code into my block however my code worked but direct after the rest of the page wanted to read from my "_dkp" database instead of my "_portal" database.
Without actual access to the database (which I am not asking for) and/or knowing the table's structure, it will be difficult to make it work sight-unseen.
This was a quick attempt to demonstrate what would be needed to change over to another database table.
Database Error: Table '****_udkp.smf_messages' doesn't exist ... is the message i get were i have the news of the page...
the code i am using now is the same as yours i forgot to put the direct name of the database... my other database were i have my portal is on ****_portal.smf_messages' i guess.
Most likely, you will need to add code at the end of this script to change back to the SMF database so it can find the tables for SMF since the block returns control back to SMF. It would very similar to the top of the script with your SMF information.
got it all working now thank you allot for you help and effort!
Glad it worked for you... 8)
Working for me as well, with the modification for running EQDKP in a different database.
is it possible to add 5 latest loot inside [wowitem]itemname[/wowitem] bellow this "quick" dkp i mean it should be about the same code right? :/
Quote from: maviel on May 05, 2009, 08:14:15 AM
is it possible to add 5 latest loot inside [wowitem]itemname[/wowitem] bellow this "quick" dkp i mean it should be about the same code right? :/
Its about the same, i think i have somewhere the code handy but not at home right now, when i and if i find it i will add it in a new topic.
Just for reference i suggest to remove the WoWitem Modification, check my guide found here (http://www.tinyportal.net/index.php/topic,29447.0.html) and follow the step to install the WOWHead tooltips.
This code does not work in 2.0.
Here's my edit - Anyone care to help me with why not? I think it's something with the db_query function.
global $db_prefix, $context, $user_info, $ID_MEMBER;
$EQPrefix = "eqdkp_";
echo '<center>';
$sql1 = "SELECT * FROM {$EQPrefix}members WHERE member_name='" . $context['user']['name'] ."'";
if ($context['user']['is_logged']){
$request = db_query($sql1, __FILE__, __LINE__);
$row = mysql_fetch_assoc($request);
if (empty($row['member_name'])){
echo '<a href="http://dkp.harmswayguild.com/">Your account has errors. Contact Quantic or Revolut</a>.<br>';
}
else
{
$totaldkp=$row['member_earned'] - $row['member_spent'] + $row['member_adjustment'];
echo '<a href="http://dkp.harmswayguild.com/">You have '. $totaldkp .' DKP</a>.<br>';
}
};
if (!$context['user']['is_logged']){
echo 'SERIOUS ERROR - CONTACT LUCUTIOUS';
}
echo '</center>';
This should probably work.
global $context, $user_info, $smcFunc;
echo '<center>';
if ($context['user']['is_logged'])
{
$request = $smcFunc['db_query']('', '
SELECT * FOM eqdkp_members
WHERE member_name = {string:name}',
array('name' => $context['user']['name'])
);
$row = $smcFunc['db_fetch_assoc']($request);
if (empty($row['member_name']))
{
echo '
<a href="http://dkp.harmswayguild.com/">Your account has errors. Contact Quantic or Revolut</a>.<br>';
}
else
{
$totaldkp = $row['member_earned'] - $row['member_spent'] + $row['member_adjustment'];
echo '<a href="http://dkp.harmswayguild.com/">You have '. $totaldkp .' DKP</a>.<br>';
}
}
if (!$context['user']['is_logged'])
{
echo 'SERIOUS ERROR - CONTACT LUCUTIOUS';
}
$smcFunc['db_free_results']($request);
echo '</center>';