• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[ZNOTE] Marriage problem

lubunttu

New Member
Joined
May 17, 2016
Messages
107
Reaction score
2
@forgee and @Zisly made this characterprofile.php
http://hastebin.com/alujugofej.xml

To show in character profile who is marriage, using this marriage system:
https://otland.net/threads/marriage-system-8-6-fixed.161590/

But only in Wife's page show marriage:
In wife page's show:
Married to: Noivo

And in husband page show:
Married to: No-one.

Looking in DataBase (in phpmyadmin) show me this in marriage_system:
Code:
id | player_id | partner | marriage_date
 1 |        4       |       2      |    1476275237


Why? Anyone know how to fix it?
 
Solution
PHP:
<!-- Marriage Data -->
<?php
$married_to = mysql_select_single("SELECT `partner`, `player_id`, `marriage_date` FROM `marriage_system` WHERE `player_id` = '".$user_id."' OR `partner` = '".$user_id."' LIMIT 1;");
if ($married_to !== false) {
    $partner = ($married_to['player_id'] == $user_id) ? $married_to['partner'] : $married_to['player_id'];
    $partner = user_character_name($partner);
    ?>
    <li>
        <b>Married to:</b>
        <a href="characterprofile.php?name=<?php echo $partner; ?>">
            <?php echo $partner; ?>
        </a> since <?php echo getClock($married_to['marriage_date'], true, true); ?>
    </li>
    <?php
} else {
    ?>
    <li><b>Married to:</b> No-one.</li>
    <?php
}
?>
According to the thread you linked to the database should be like this:
Code:
CREATE TABLE marriage_system (
    id                INTEGER NOT NULL,
    player_id         INTEGER NOT NULL,
    partner           VARCHAR( 255 )  NOT NULL,
    marriage_date     INTEGER NOT NULL,
    PRIMARY KEY ( id )
);

Which means the partner column should contain a name (varchar), not a player id (integer).

PHP:
<!-- Marriage Data -->
<?php
$married_to = mysql_select_single("SELECT `partner`, `marriage_date` FROM `marriage_system` WHERE `player_id` = '".(int)$user_id."' LIMIT 1;");
if ($married_to !== false) {
    ?>
    <li>
        <b>Married to:</b>
        <a href="characterprofile.php?name=<?php echo $married_to['partner']; ?>">
            <?php echo $married_to['partner']; ?>
        </a> since <?php echo getClock($married_to['marriage_date'], true, true); ?>
    </li>
    <?php
} else {
    ?>
    <li><b>Married to:</b> No-one.</li>
    <?php
}
?>

Though it is a chance the creator of that marriage system decided to store character ID as a varchar for whatever reason in the database. In which case you may want to
AFTER THIS:
if ($married_to !== false) {

ADD THIS:
$married_to['partner'] = user_character_name((int)$married_to['partner']);
 
Last edited:
According to the thread you linked to the database should be like this:
Code:
CREATE TABLE marriage_system (
    id                INTEGER NOT NULL,
    player_id         INTEGER NOT NULL,
    partner           VARCHAR( 255 )  NOT NULL,
    marriage_date     INTEGER NOT NULL,
    PRIMARY KEY ( id )
);

Which means the partner column should contain a name (varchar), not a player id (integer).

PHP:
<!-- Marriage Data -->
<?php
$married_to = mysql_select_single("SELECT `partner`, `marriage_date` FROM `marriage_system` WHERE `player_id` = '".(int)$user_id."' LIMIT 1;");
if ($married_to !== false) {
    ?>
    <li>
        <b>Married to:</b>
        <a href="characterprofile.php?name=<?php echo $married_to['partner']; ?>">
            <?php echo $married_to['partner']; ?>
        </a> since <?php echo getClock($married_to['marriage_date'], true, true); ?>
    </li>
    <?php
} else {
    ?>
    <li><b>Married to:</b> No-one.</li>
    <?php
}
?>

Though it is a chance the creator of that marriage system decided to store character ID as a varchar for whatever reason in the database. In which case you may want to
AFTER THIS:
if ($married_to !== false) {

ADD THIS:
$married_to['partner'] = user_character_name((int)$married_to['partner']);


DB:
Code:
CREATE TABLE `marriage_system` (
   `id` INT NOT NULL AUTO_INCREMENT,
   `player_id` INT NOT NULL,
   `partner` VARCHAR(255) NOT NULL,
   `marriage_date` INT NOT NULL,
   PRIMARY KEY (`id`)
) ENGINE = InnoDB;

I tried what u said
http://hastebin.com/yasuhiyaje.xml

But not work...
When i go to husband page, didnt show nothing
Show this
Married to:
 
Doing this on wife page still working, but on husband page show me:
Married to: No-one.
According to the function mysql_select_single in Znote's sources it returns either a string from the database or false.
So the code I provided you with returns true if the contents of $married_to['partner'] is not an empty string or false and executes the if statement.
If $married_to['partner'] contains false or is an empty string then the condition returns false and the else statement executes.

I have not reviewed his code any further.
 
Here you can test it yourself if you like just change the value of $married_to
PHP:
<html>
<head>
</head>
<body>
<?php
    $married_to['partner'] = "Someone";
    if( preg_match('/^\S/', $married_to['partner']) ){
         echo "Married to " . $married_to['partner'];
    }else{
         echo "Married to no one";
    }
?>
</body>
</html>
 
Idk if i will explain right

id player_id
partner marriage_date
1 4 2 1476275237

Marriage ID 1 =
playerid 4 (Playerid from: Esposa [wife])

Its working on characterprofile.php showing Noivo is her partner

partner 2 (Playerid from: Noivo [husband])
Its not working on characterprofile.php its showing no one is him partner
 
Idk if i will explain right

id player_id
partner marriage_date
1 4 2 1476275237

Marriage ID 1 =
playerid 4 (Playerid from: Esposa [wife])

Its working on characterprofile.php showing Noivo is her partner

partner 2 (Playerid from: Noivo [husband])
Its not working on characterprofile.php its showing no one is him partner

upppp
 
Hmm, could it be that both players share the same record in the db?
PHP:
$married_to = mysql_select_single("SELECT `partner`, `marriage_date` FROM `marriage_system` WHERE `player_id` = '".(int)$user_id."' OR `partner` = '".(int)$user_id."' LIMIT 1;");

If that works, chances are it will give same name in both characterprofiles, you may also need to check which column is the user id and use the other one to display on the profile.
 
Hmm, could it be that both players share the same record in the db?
PHP:
$married_to = mysql_select_single("SELECT `partner`, `marriage_date` FROM `marriage_system` WHERE `player_id` = '".(int)$user_id."' OR `partner` = '".(int)$user_id."' LIMIT 1;");

If that works, chances are it will give same name in both characterprofiles, you may also need to check which column is the user id and use the other one to display on the profile.

Thanks, but not work bro
Show only:
Married to:
 
You can't just tell people "not work bro" and expect to get a solution, you need to explain the changes you made if any, the more information you provide about a problem the easier it is to find a solution.

Hmm, could it be that both players share the same record in the db?
PHP:
$married_to = mysql_select_single("SELECT `partner`, `marriage_date` FROM `marriage_system` WHERE `player_id` = '".(int)$user_id."' OR `partner` = '".(int)$user_id."' LIMIT 1;");

If that works, chances are it will give same name in both characterprofiles, you may also need to check which column is the user id and use the other one to display on the profile.

Made it changes not show marriage name in wife and not show in husband...

http://hastebin.com/ezuzegirom.xml

It's save:
id | player_id | partner | marriage_date
1 | 4 | 2 | 1476275237


id = marriage ID
player_id = wife
partner = husband
marriage_data = date
 
Below:
PHP:
$married_to['partner'] = user_character_name((int)$married_to['partner']);

Add:
PHP:
var_dump($married_to);

This should give you some debug info, tell me what that is.
 
Below:
PHP:
$married_to['partner'] = user_character_name((int)$married_to['partner']);

Add:
PHP:
var_dump($married_to);

This should give you some debug info, tell me what that is.

Wife page:
  • Country:
    .png

    array(2) { ["partner"]=> string(5) "Noivo" ["marriage_date"]=> string(10) "1476275237" }
  • Married to:
  • Sex: Female

Husband page:
  • Country:
    .png

    array(2) { ["partner"]=> string(5) "Noivo" ["marriage_date"]=> string(10) "1476275237" }
  • Married to:
  • Sex: Male
 
PHP:
<!-- Marriage Data -->
<?php
$married_to = mysql_select_single("SELECT `partner`, `player_id`, `marriage_date` FROM `marriage_system` WHERE `player_id` = '".$user_id."' OR `partner` = '".$user_id."' LIMIT 1;");
if ($married_to !== false) {
    $partner = ($married_to['player_id'] == $user_id) ? $married_to['partner'] : $married_to['player_id'];
    $partner = user_character_name($partner);
    ?>
    <li>
        <b>Married to:</b>
        <a href="characterprofile.php?name=<?php echo $partner; ?>">
            <?php echo $partner; ?>
        </a> since <?php echo getClock($married_to['marriage_date'], true, true); ?>
    </li>
    <?php
} else {
    ?>
    <li><b>Married to:</b> No-one.</li>
    <?php
}
?>
 
Last edited:
Solution
PHP:
<!-- Marriage Data -->
<?php
$married_to = mysql_select_single("SELECT `partner`, `player_id`, `marriage_date` FROM `marriage_system` WHERE `player_id` = '".$user_id."' OR `partner` = '".$user_id."' LIMIT 1;");
if ($married_to !== false) {
    $partner = ($married_to['player_id'] == $user_id) ? $married_to['partner'] : $married_to['player_id'];
    $partner = user_character_name($partner);
    ?>
    <li>
        <b>Married to:</b>
        <a href="characterprofile.php?name=<?php echo $partner; ?>">
            <?php echo $partner; ?>
        </a> since <?php echo getClock($married_to['marriage_date'], true, true); ?>
    </li>
    <?php
} else {
    ?>
    <li><b>Married to:</b> No-one.</li>
    <?php
}
?>

PERFECT !!!!!!!!!!!!!!!
TY YOU A LOT ZNOTE!
 
Back
Top