Scratch made Roster/DB connection
Posted: Sat Oct 19, 2013 6:28 pm
Just started working on this. Could NEVER get the other one to work, so finally gave in, and sat down to learn some basic PHP SQL all over again (its been 10~years since I ever used it..and even then was basic)
This seems to work fine, obviously this is just an output, and can be modified like crazy, can add more info to it, etc. Its fairly easy to tweak once its setup. Enjoy!
The above is for players online, and what zone they're in. THis is EXTREMELY basic but can be built on quite a bit (as I plan to). Another example of this type of connection, which obviously DSP already planned on with the Audit_CHAT function, and could be modified if you dig into the C Headers for yell/shout/etc.
Obviously a stupid sample of really simple code, but more of a proof of concept. Both are live on my site:
http://bnet.cc/ffxi/index.php -- Users Online
http://bnet.cc/ffxi/chat.php -- Chat (Audits only Yell/Shouts for now, manually modified the rest to not display here as I was worried about ballooning the database. Could easily add a script to this to go into the database and delete anything older than say.. 5 days? But thats future.
Best Regards,
Tagban
This seems to work fine, obviously this is just an output, and can be modified like crazy, can add more info to it, etc. Its fairly easy to tweak once its setup. Enjoy!
Code: Select all
<?php
//use 127.0.0.1 if hosted on same server as ffxi server
//for databasename, by default if you followed instructions, is dspdb
mysql_connect("yourdatabaseip", "dbusername", "dbpassword") or die(mysql_error());
mysql_select_db("databasename") or die(mysql_error());
$query = "SELECT chars.charid, chars.charname, accounts_sessions.charid, zone_settings.zoneid, zone_settings.name, chars.pos_zone FROM accounts_sessions, chars, zone_settings WHERE accounts_sessions.charid = chars.charid AND zone_settings.zoneid = chars.pos_zone";
$result = mysql_query($query) or die(mysql_error());
// Print out the contents of each row into a table
while($row = mysql_fetch_array($result)){
echo $row['charname']. " - ". $row['name'];
echo "<br />";
}
?>
Code: Select all
<?php
mysql_connect("SERVERIP", "SQLUSER", "SQLPASS") or die(mysql_error());
mysql_select_db("DATABASENAME") or die(mysql_error());
$query = "SELECT * FROM audit_chat";
$result = mysql_query($query) or die(mysql_error());
// Print out the contents of each row into a table
while($row = mysql_fetch_array($result)){
echo $row['datetime'] . " : " . $row['speaker']. " - ". $row['message'] ." - (" . $row['type'] .")";
echo "<br />";
}
?>
http://bnet.cc/ffxi/index.php -- Users Online
http://bnet.cc/ffxi/chat.php -- Chat (Audits only Yell/Shouts for now, manually modified the rest to not display here as I was worried about ballooning the database. Could easily add a script to this to go into the database and delete anything older than say.. 5 days? But thats future.
Best Regards,
Tagban