pauly / php-gedcom

I wanted some simple php code for parsing a gedcom file to integrate the family tree with my existing website, and this is it.
6 stars 4 forks source link

Uncaught Error: Call to a member function id() on string in #1

Open ghost opened 2 years ago

ghost commented 2 years ago

Hi.

I want to show the relationships between 2 people for my visitors, but when I use _relationship, I get the following error:

Fatal error: Uncaught Error: Call to a member function id() on string in /var/www/html/genealogy/Person.php:628 Stack trace: #0 /var/www/html/genealogy/index.php(243): Person->_relationship() #1 {main} thrown in /var/www/html/genealogy/Person.php on line 628

I use the following:

foreach($gedcom['INDI'] AS $person) {
    $person = new Person($person, $gedcom);
    echo $person->_relationship('Alfred Johansson');
}

I get the same error message when I try to replace $person->_relationship('Alfred Johansson'); with $person->relationship(['Alfred Johansson','Anders Karlsson']);

How to resolve?

pauly commented 2 years ago

been a while since I looked at this code but you need to pass an array of objects as a param there, not just their name

foreach ($gedcom['INDI'] AS $person) { $person = new Person($person, $gedcom); echo $person->_relationship([$person->mother()->father()->mother()]);

}

On Sun, 2 Jan 2022 at 18:06, Airikr @.***> wrote:

Hi.

I want to show the relationships between 2 people for my visitors, but when I use _relationship, I get the following error:

Fatal error: Uncaught Error: Call to a member function id() on string in /var/www/html/genealogy/Person.php:628 Stack trace: #0 /var/www/html/genealogy/index.php(243): Person->_relationship() #1 {main} thrown in /var/www/html/genealogy/Person.php on line 628

I use the following:

foreach($gedcom['INDI'] AS $person) { $person = new Person($person, $gedcom); echo $person->_relationship('Alfred Johansson'); }

I get the same error message when I try to replace $person->_relationship('Alfred Johansson'); with $person->relationship(['Alfred Johansson','Anders Karlsson']);

How to resolve?

— Reply to this email directly, view it on GitHub https://github.com/pauly/php-gedcom/issues/1, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACMZM7LDO2DVHN34AVJMK3UUCHZPANCNFSM5LD5EPLA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you are subscribed to this thread.Message ID: @.***>

pauly commented 2 years ago

I rewrote this in javascript about five years ago I can probably support that a bit better as that's what I'm using to generate my own website http://www.clarkeology.com

On Mon, 3 Jan 2022 at 10:58, Pauly @.***> wrote:

been a while since I looked at this code but you need to pass an array of objects as a param there, not just their name

foreach ($gedcom['INDI'] AS $person) { $person = new Person($person, $gedcom); echo $person->_relationship([$person->mother()->father()->mother()]);

}

On Sun, 2 Jan 2022 at 18:06, Airikr @.***> wrote:

Hi.

I want to show the relationships between 2 people for my visitors, but when I use _relationship, I get the following error:

Fatal error: Uncaught Error: Call to a member function id() on string in /var/www/html/genealogy/Person.php:628 Stack trace: #0 /var/www/html/genealogy/index.php(243): Person->_relationship() #1 {main} thrown in /var/www/html/genealogy/Person.php on line 628

I use the following:

foreach($gedcom['INDI'] AS $person) { $person = new Person($person, $gedcom); echo $person->_relationship('Alfred Johansson'); }

I get the same error message when I try to replace $person->_relationship('Alfred Johansson'); with $person->relationship(['Alfred Johansson','Anders Karlsson']);

How to resolve?

— Reply to this email directly, view it on GitHub https://github.com/pauly/php-gedcom/issues/1, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACMZM7LDO2DVHN34AVJMK3UUCHZPANCNFSM5LD5EPLA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you are subscribed to this thread.Message ID: @.***>

ghost commented 2 years ago

been a while since I looked at this code but you need to pass an array of objects as a param there, not just their name foreach ($gedcom['INDI'] AS $person) { $person = new Person($person, $gedcom); echo $person->_relationship([$person->mother()->father()->mother()]); }

Thank you for your reply. Unfortunately, that solution didn't work either 😕 I get the same error.

I rewrote this in javascript about five years ago I can probably support that a bit better as that's what I'm using to generate my own website http://www.clarkeology.com

Yeah, I have starred that repo too 🙂 I'll give it a go when I have more time, but I would prefer to use as less JavaScript as possible (don't ask me why, haha).