We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20400
    • 37 Posts
    I want to return an alert message to the user if there is an error in updating the data base. I have loaded the doucument parser so I can use $modx call, but haven’t loaded any other classes. The user is logged in type=web and my code is accessed using an AJAX call that expects a Javascript to be returned.

    To test the code I used an empty string, $sq, and the following code:

    $modx->getSettings();
    if($result = $modx->db->query($sq)) {
    $msg = $modx->getChunk(’msgSidebarAdProcessed’);
    return "alert(’" . $msg . "’);";
    } else {
    $msg = $modx->getChunk(’errProcessingFailed’);
    return "alert(’" . $msg . "’);";
    }

    The error is being written to the event log, however, I don’t return to this code and the alert isn’t sent back to the user. It looks like the program exits after writing the event log.

    I know I could establish a connection outside the document parser, and use mySQL commands, however, I would rather not take that route. I looked at the DBAPI, but can’t see where the errors are being trapped.

    I tried using $modx->db->insert(. . .) - but the results were the same.

    Any help would be appreciated
      • 20400
      • 37 Posts
      There is some perverse Coding God that only lets me find the solution to a problem after I have posted a request for help. rolleyes

      The solution is in the messageQuit function in the document parser. I am going to add a custom error message routine near line 2619. And, I will probable try SiSt’s suggestion in http://modxcms.com/forums/index.php/topic,17044.0.html.