We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40122
    • 330 Posts
    Hi all,

    This is a bit of an odd one:

    I have a php file in the my root directory that I want to connect to the modx database for JSON purposes.

    I have examined the index file in the root directory and see the following:

    // initialize the variables prior to grabbing the config file
    $database_type = '';
    $database_server = '';
    $database_user = '';
    $database_password = '';
    $dbase = '';
    $table_prefix = '';
    $base_url = '';
    $base_path = '';
    
    // get the required includes
    if($database_user=="") {
    	$rt = @include_once(dirname(__FILE__).'/manager/includes/config.inc.php');


    ETC

    I was wondering if anyone knew how to adapt that for my file?

    So I could connect and run queries straight of it?

    Thanks!
      • 40122
      • 330 Posts
      I have solved it. I just included that entire config file with:

      include_once(dirname(__FILE__).'/manager/includes/config.inc.php


      One thing to be wary of: ModX includes `` either side of the database name. eg: `modx_dbname` so you have to remove those before you drop it in to your mysql connect