We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 16858
    • 58 Posts
    no, I do not have that installed, but if I telnet into my server and paste the query directly into mysql, it works fine ... its something in php.
      • 10487 MODX Staff
      • 1,535 Posts
      Hmm, strange problem indeed. What is your PHP code for defining the query? I’m siding with it being a problem in the PHP code as well.

        Garry Nutting
        Senior Developer
        MODX, LLC

        Email: [email protected]
        Twitter: @garryn
        Web: modx.com
        • 16858
        • 58 Posts
        Below is the code I am using ... the reason for the check to see if a variable starts with an underscore is because I reserve variables starting with an underscore for system information not contained in the database.

        $v = "";
        foreach ($_POST as $key => $value) {
            if (substr($key,0,1) != "_") {
                if (trim($value)) {
                    if (!$v) {
                        $v .= $key . ' LIKE ' . '"%' . $value . '%" ';
                    } else {
                        $v .= 'AND ' . $key . ' LIKE "%' . $value . '%" ';
                    }
                }
            }
        }
        $_query = 'SELECT * FROM victim_assistance WHERE ' . $v;
        $ds = $modx->db->query($_query);
        $_row = $modx->db->getRow($ds);
          • 33372
          • 1,611 Posts
          I haven’t tested this logic myself, but have you tested that the queries are being formed properly by printing them out? The if (!$v) test jumps out at me as a possible problem, since you have defined $v earlier (blank, but defined), which might make the query jump right to the AND logic instead of the original LIKE statement. That wouldn’t explain the specific error that you say you’re receiving, but at least viewing the queries as they’re formed in PHP would be helpful to debug any error in logic that might be hiding in plain sight.
            "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