On March 26, 2019 we launched new MODX Forums. Please join us at the new MODX Community Forums.
Subscribe: RSS
  • Presuming I entered the line correctly
    $query=mysql_query("$modx->db->query"); 
    


    The result was;

    « MODx Parse Error »

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

    PHP error debug
    Error: Object of class DBAPI could not be converted to string
    Error type/ Nr.: - 4096
    File: /home/fiveep/public_html/assets/snippets/maxigallery/maxigallery.php
    Line: 241
    Line 241 source: $query=mysql_query("$modx->db->query");

    Parser timing
    MySQL: 0.0052 s (5 Requests)
    PHP: 0.2392 s
    Total: 0.2444 s
    Error while inserting event log into database.
    • Ahah!

      I entered the line incorrectly, just corrected it to replace the mysql_query bit and presto, the page now works! smiley

      So, will this code be okay leaving it as it is, or would this be only a temp fix?

      Many thanks for all the trouble you have taken over this! :-D
      • That should solve your problem. Keep this in mind when you start writing your own snippets, always use the MODx dbapi!
          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
        • Excellent, many thanks! cool
          • I’ll make sure that it gets fixed for next release...


              "He can have a lollipop any time he wants to. That's what it means to be a programmer."
            • Obscure type of bug, the other php app must be using pconnect and not closing when finished.
                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
              • Yes, obscure type of bug.
                Had the same one after migrating a website.

                Old site (MaxiGallery working well):
                Hosting: Yellis.net
                PHP 5.3.29
                MySQL 5.5.47
                MODx 1.0.3
                magic_quotes_gpc Off
                magic_quote_runtime Off

                New site:
                Hosting: Infomaniak.website (URL for site preview)
                PHP 5.6.22
                MySQL 5.0.11-dev
                MODX 1.1
                magic_quotes_gpc ?(status not mentioned by phpinfo.php)
                magic_quote_runtime ?(status not mentioned by phpinfo.php)


                By echoing $mg->pics_tbl, I observed that the table name doesn't have back quotes around it.

                When trying $query=mysql_query("$modx->db->query"); as SimonMW did, this error was returned
                "Error : Object of class DBAPI could not be converted to string"

                I verified the table in phpMyAdmin and it had no defect.

                Solved the issue by simply commenting out the whole "validate table" block in maxigallery.php:
                //validate gallery table
                /*
                $query=mysql_query("DESC $mg->pics_tbl");
                
                if(!$query) {
                  ...
                } else {
                  ...
                }
                */

                Works. But of course, a patch would be appreciated.

                Maybe does the error come from MySQL as I see Infomaniak is using an older "dev" MySQL client for preview URLs, or some server settings.