Closed spiffynacho closed 2 months ago
In reviewing my PHP error log, I found the following entry related to the issue was repeated:
[Wed Jan 03 14:46:29.540172 2024] [php:error] [pid 6272:tid 1916] [client *****] PHP Fatal error: Uncaught mysqli_sql_exception: Unknown character set: 'utf' in C:\\xampp\\htdocs\\scientia\\playermap\\func.php:39\nStack trace:\n#0 C:\\xampp\\htdocs\\scientia\\playermap\\func.php(39): mysqli_query(Object(mysqli), 'SET NAMES utf-8')\n#1 C:\\xampp\\htdocs\\scientia\\playermap\\pomm_play.php(25): DBLayer->query('SET NAMES utf-8')\n#2 {main}\n thrown in C:\\xampp\\htdocs\\scientia\\playermap\\func.php on line 39, referer: https://scientia.access.ly/playermap/
AzerothCore uses the "utf8mb4" charset. I can confirm my databases are using that standard.
I worked through the code and discovered a few things and have partially-resolved the issue. First, I made the following code changes in playermap_config.php:
$site_encoding = "utf8";
PHP 8 does not recognize utf-8, so reformatting the encoding type resolves that error. Next, I noticed leaderGuid is in the groups table, not the group_member table. To resolve this issue, I modified the query:
// ... [previous code]
$characters_db = new DBLayer($host, $user, $password, $db); if (!$characters_db->isValid()) { $_RESULT['status']['online'] = 2; exit(); } $characters_db->query("SET NAMES $database_encoding");
// Modify this query to join 'group_member' with 'groups'
$query = $characters_db->query(
"SELECT gm.memberGuid
, g.leaderGuid
FROM group_member
gm
JOIN groups
g ON gm.groupId = g.id
WHERE gm.memberGuid
IN (SELECT guid
FROM characters
WHERE online
='1')"
);
if ($query) { while ($result = $characters_db->fetch_assoc($query)) { $groups[$result['memberGuid']] = $result['leaderGuid']; } }
// ... [rest of the code]
Next, groupId is not a column in the group_member table. I modified the query to reflect the correct column:
// ... [previous code]
$characters_db = new DBLayer($host, $user, $password, $db); if (!$characters_db->isValid()) { $_RESULT['status']['online'] = 2; exit(); } $characters_db->query("SET NAMES $database_encoding");
// Updated query to join 'group_member' and 'groups' tables using 'Guid'
$query = $characters_db->query(
"SELECT gm.memberGuid
, g.leaderGuid
FROM group_member
gm
JOIN groups
g ON gm.Guid = g.Guid
WHERE gm.memberGuid
IN (SELECT guid
FROM characters
WHERE online
='1')"
);
if ($query) { while ($result = $characters_db->fetch_assoc($query)) { $groups[$result['memberGuid']] = $result['leaderGuid']; } }
// ... [rest of the code]
Next, I received an error about status being referenced before it was defined. To correct this, I modified the code:
<?php
require_once("defines.php");
// ... [other require_once calls]
$_RESULT = null;
$status = []; // Initialize $status
// ... [rest of your code]
if ($show_status) {
$query = $realm_db->query("SELECT UNIX_TIMESTAMP(),`starttime`,`maxplayers` FROM `uptime` WHERE `starttime`=(SELECT MAX(`starttime`) FROM `uptime`)");
if ($result = $realm_db->fetch_row($query)) {
$status['online'] = test_realm() ? 1 : 0;
$status['uptime'] = $result[0] - $result[1];
$status['maxplayers'] = $result[2];
$status['gmonline'] = $gm_online;
} else {
$status = null; // Or set to some default value
}
} else {
$status = null; // Or set to some default value
}
// ... [rest of your code]
$res['status'] = $status; // This line is now using an initialized variable
$_RESULT = $res;
// ... [rest of your code]
?>
The map now shows the online time, but it says no players are online, even though I know players ARE online. https://scientia.access.ly/playermap/
I think that you have a wrong AC version, I've just tried to run it on acore-docker and it works perfectly
I can confirm that I am using the latest build. If you look on GitHub, the variables referenced in the code are in different tables.
your tables seems correct, I have the same, indeed playermap should need some updates about that, but the main functionalities should work anyway
try to put instead of 127.0.0.1:3306
as 'addr' the realmlist scientia.access.ly:3306
I manually compiled AzerothCore using the instructions here: https://www.azerothcore.org/wiki/classic-installation I understand you are using Docker. That's one difference that may be an issue. Which version of PHP are you running?
php 8.0.8 using MAMP
I worked through the code and discovered a few things and have partially-resolved the issue. First, I made the following code changes in playermap_config.php:
$site_encoding = "utf8";
PHP 8 does not recognize utf-8, so reformatting the encoding type resolves that error. Next, I noticed leaderGuid is in the groups table, not the group_member table. To resolve this issue, I modified the query:
// ... [previous code]
$characters_db = new DBLayer($host, $user, $password, $db); if (!$characters_db->isValid()) { $_RESULT['status']['online'] = 2; exit(); } $characters_db->query("SET NAMES $database_encoding");
// Modify this query to join 'group_member' with 'groups' $query = $characters_db->query( "SELECT gm.
memberGuid
, g.leaderGuid
FROMgroup_member
gm JOINgroups
g ON gm.groupId = g.id WHERE gm.memberGuid
IN (SELECTguid
FROMcharacters
WHEREonline
='1')" );if ($query) { while ($result = $characters_db->fetch_assoc($query)) { $groups[$result['memberGuid']] = $result['leaderGuid']; } }
// ... [rest of the code]
Next, groupId is not a column in the group_member table. I modified the query to reflect the correct column:
// ... [previous code]
$characters_db = new DBLayer($host, $user, $password, $db); if (!$characters_db->isValid()) { $_RESULT['status']['online'] = 2; exit(); } $characters_db->query("SET NAMES $database_encoding");
// Updated query to join 'group_member' and 'groups' tables using 'Guid' $query = $characters_db->query( "SELECT gm.
memberGuid
, g.leaderGuid
FROMgroup_member
gm JOINgroups
g ON gm.Guid = g.Guid WHERE gm.memberGuid
IN (SELECTguid
FROMcharacters
WHEREonline
='1')" );if ($query) { while ($result = $characters_db->fetch_assoc($query)) { $groups[$result['memberGuid']] = $result['leaderGuid']; } }
// ... [rest of the code]
Next, I received an error about status being referenced before it was defined. To correct this, I modified the code:
<?php require_once("defines.php"); // ... [other require_once calls] $_RESULT = null; $status = []; // Initialize $status // ... [rest of your code] if ($show_status) { $query = $realm_db->query("SELECT UNIX_TIMESTAMP(),`starttime`,`maxplayers` FROM `uptime` WHERE `starttime`=(SELECT MAX(`starttime`) FROM `uptime`)"); if ($result = $realm_db->fetch_row($query)) { $status['online'] = test_realm() ? 1 : 0; $status['uptime'] = $result[0] - $result[1]; $status['maxplayers'] = $result[2]; $status['gmonline'] = $gm_online; } else { $status = null; // Or set to some default value } } else { $status = null; // Or set to some default value } // ... [rest of your code] $res['status'] = $status; // This line is now using an initialized variable $_RESULT = $res; // ... [rest of your code] ?>
The solution in the pomm_play.php:
$query = $characters_db->query("SELECT `guid` as `leaderGuid`,`memberGuid` FROM `group_member` WHERE `memberGuid` IN(SELECT `guid` FROM `characters` WHERE `online`='1')");
I tried and it worked!
on chromiecraft.com we keep the core update and we are still using the same version of this repository
the playermap still works without changing that SQL query
https://www.chromiecraft.com/en/playermap/ with last commit 41e28ee24c7e501430b71107ac90176d8abaaa02
We should do a docker container of this playermap to make it always work in any case without changing anything
I followed the installation instructions by editing playermap_config.php and pomm_conf.php. The map loads, but no data is displayed: https://scientia.access.ly/playermap/. I added the following to index.php:
No errors are displayed. I am running PHP 8.2.4. Here is the content of my playermap_config.php file, with the MySQL login omitted:
And here is my pomm_conf.php file: