We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7923
    • 4,213 Posts
    I don’t know the exact code that is being evaled, but there is some error on line 10 in it. From your first post, there is a $ missing before modx variables..


      "He can have a lollipop any time he wants to. That's what it means to be a programmer."
      • 10395
      • 96 Posts
      I’m now getting:


      Warning: array_keys(): The first argument should be an array in /includes/functions.php on line 3699

      Warning: Invalid argument supplied for foreach() in /includes/functions.php on line 3699

      Fatal error: Call to a member function on a non-object in /home/gaia/public_html/new_er/testvb/includes/functions.php on line 2772
        • 33372
        • 1,611 Posts
        Quote from: doze at Jan 25, 2007, 04:09 PM

        I don’t know the exact code that is being evaled, but there is some error on line 10 in it. From your first post, there is a $ missing before modx variables..

        Doze is right. It should be:
        $modx->setPlaceholder(’members’, $members);

        If you already fixed that (in both places), then what is the rest of your code?
          "Things are not what they appear to be; nor are they otherwise." - Buddha

          "Well, gee, Buddha - that wasn't very helpful..." - ZAP

          Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Perhaps that chdir bit is causing a problem... try using a full path to the include file, or use lots of ../../ to get a proper relative path. The relative path would be from your MODx root, where the main index.php is located, since that’s where everything is working from.

          So if your include file was in a folder off of your site root, and MODx was installed in the site root, it would be
          otherapp/path/to/includefile.php

          or if MODx were installed in a folder of its own
          ../otherapp/path/to/includefile.php

            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 10395
            • 96 Posts
            Thanks for the suggestions, but still a no-go.

            With your suggestion sottwell, it doesn’t seem to work, because after the call for global.php works, global.php has other files included, which dont have the relative path:


            « MODx Parse Error »
            MODx encountered the following error while attempting to parse the requested resource:
            « PHP Parse Error »

            PHP error debug
            Error: main(/home/gaia/public_html/new_er/includes/init.php): failed to open stream: No such file or directory
            Error type/ Nr.: Warning - 2
            File: /home/gaia/public_html/new_er/testvb/global.php
            Line: 20
            Line 20 source: require_once(CWD . ’/includes/init.php’);

            Parser timing
            MySQL: 0.0059 s (5 Requests)
            PHP: 0.0416 s
            Total: 0.0475 s

            See where it has the first path in the error? there should be a /new_er/testvb/includes/etc...

            I can’t edit my global.php file, because then that would mess up my vBulletin install....

            The whole code that i posted above is the only code in the snippet. It is the complete code...

            <?php
            
            //Get the global.php file from the vB install
            require_once('../new_er/testvb/global.php'); 
            
            //Fetch the total number of members.
            $tmp1 = $vbulletin->db->query_read("SELECT * FROM users");
            $members = $vbulletin->db->num_rows($tmp1);
            $modx->setPlaceholder('members', $members);
            
            //Fetch the total number of topics
            $tmp2 = $vbulletin->db->query_read("SELECT * FROM thread");
            $topics = $vbulletin->db->num_rows($tmp2);
            $modx->setPlaceholder('topics', $topics);
            
            ?>
            
              • 33372
              • 1,611 Posts
              I think that you should try editing vb’s global.php flie and make all of the paths absolute instead of relative. i don’t think that should mess up your install at all. Or you could try setting the directory to what you need for vb to work at the beginning of your snippet (as you do now), but return it to its original value at the end of the snippet.
                "Things are not what they appear to be; nor are they otherwise." - Buddha

                "Well, gee, Buddha - that wasn&#39;t very helpful..." - ZAP

                Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
                • 22303 MODX Staff
                • 10,725 Posts
                Yes, most integrations of existing applications like this break because MODx is always running from the root location of the MODx site (i.e. index.php), and these other applications assume all their internal paths will be handled from their own root. Properly designed applications should not make this assumption and would use a calculated root path for the application to respect when referencing/including any additional files; otherwise, you’re going to have to hack that 3rd party app to death to make it work in the MODx paradigm...
                  • 10395
                  • 96 Posts
                  Hmm, i’m just going to make a connection to the database within the snippet myself. Seems like it will be less of a hassle.

                  Thanks.