We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37946
    • 70 Posts
    I think I'm kinda stuck at a trivial point.

    I have an html file that I am making ajax requests out to a php file. I would like to have that php file query the modx db for what I am looking for, and return the results as I need (format etc).

    This is what I have so far - using this API page as reference.

    file.php
    require_once MODX_CORE_PATH . 'model/modx/modx.class.php';
    
    $modx = new modX();
    $modx->initialize( 'web' );
    
    $output = '';
    	
    $result = $modx->db->query( 'SELECT id, name FROM `modx_membergroup_names` ORDER BY name ASC' );
    
    while( $row = $modx->db->getRow( $result ) ) {
        $output .= '<br /> ID: ' . $row['id'] . '<br /> Name: ' . $row['name'] . '<br />---------<br />';
    }
    
    error_log( $output );
    


    I continue to get "Notice: Undefined property: modX::$db"
    I'm not sure where I'm going wrong. Thank you for your help!
      • 4041
      • 788 Posts
      Looks like your code is a mix of Revolution and Evolution coding, which won't work smiley

      Which version of MODx are you using?
        xforum
        http://frsbuilders.net (under construction) forum for evolution
        • 37946
        • 70 Posts
        Ha!
        There's problem number 1 then. smiley

        I am (attempting) to use Revolution.
          • 4041
          • 788 Posts
          In that case, here is the Revolution developer wiki:
          http://rtfm.modx.com/display/revolution20/Developing+in+MODx

          If you get stuck holler back, I'm sure a Revo developer will chime in and help.
            xforum
            http://frsbuilders.net (under construction) forum for evolution