We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17895
    • 209 Posts
    what’s wrong with this? (this code is in a plug-in)

    $tbl = $modx->getFullTableName("site_content");
    $sql = "SELECT id, parent, contentLang, refId FROM $tbl";
    $rs = $modx->dbQuery($sql);
    while ($curPage = $modx->fetchRow($rs)) {
      if ($curPage['parent'] != 0) {
        $sql = "SELECT id, parent, contentLang, refId FROM $tbl WHERE id = ".$curPage['parent'];
        $modx->event->alert($sql);
        $rs2 = $modx->dbQuery($sql);
        if ($parent = $modx->dbQuery($rs2)) {
        }
      }
    }
    


    when it is executed, I get an error:
    « MODx Parse Error »
    MODx encountered the following error while attempting to parse the requested resource:
    « Execution of a query to the database failed - You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'Resource id #24' at line 1 »
          SQL: Resource id #24
          [Copy SQL to ClipBoard]
     
    Parser timing
      MySQL: 	0.0011 s s	(5 Requests)
      PHP: 	1136754939.3584 s s	 
      Total: 	1136754939.3596 s s
    


    If I copy/paste the query given by the event->alert function in the phpMyAdmin, the query is executed without any error
      Daniele "MadMage" Calisi
    • What is refId and contentLang? I don’t believe those are columns in the site_content table.
        • 32241
        • 1,495 Posts
        Quote from: OpenGeek at Jan 08, 2006, 09:30 PM

        What is refId and contentLang? I don’t believe those are columns in the site_content table.

        I think that’s the additional column from what madmage did for adding multi lingual capability.

        Anyway madmage, I found the problem,

            $rs2 = $modx->dbQuery($sql);
            if ($parent = $modx->dbQuery($rs2)) {
            }
        


        Why you need to query the result $rs2? I think what you want is

            $rs2 = $modx->dbQuery($sql);
            if ($parent = $modx->fetchRow($rs2)) {
            }
        


        Is that correct?
          Wendy Novianto
          [font=Verdana]PT DJAMOER Technology Media
          [font=Verdana]Xituz Media