We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 24969
    • 120 Posts
    I have the following snippet
    ...$id=$_REQUEST['dogid'];
    if(isset($id)){
         $output='';
    
         $rs=$modx->db->query('SELECT `tdog`.`callname`, `tdog`.`regname`
         FROM `tbldogs` tdog
         WHERE `tdog`.`dog_id`=`.$id.`');
         if ($modx->db->getRecordCount($rs) > 0) {
    	while ($row = $modx->db->getRow($rs)) {
                     $params['callname'] = $row['callname'];
                     $params['regname']=$row['regname'];
    		 $output.=$modx->parseChunk('Gallery', $params, '[+', '+]');
    	}
         }...

    but I get the following error when it runs
    « MODx Parse Error »
    MODx encountered the following error while attempting to parse the requested resource:
    « Execution of a query to the database failed - Unknown column '.$id.' in 'where clause' »
          SQL: SELECT `tdog`.`callname`, `tdog`.`regname` FROM `tbldogs` tdog WHERE `tdog`.`dog_id`=`.$id.
          [Copy SQL to ClipBoard]
     
    Parser timing
      MySQL: 	0.0083 s	(11 Requests)
      PHP: 	0.0618 s	 
      Total: 	0.0701 s

    Can one of you gurus find a flaw in my query or logic?
      The important thing is not to stop questioning. Curiosity has its own reason for existing. One cannot help but be in awe when he contemplates the mysteries of eternity, of life, of the marvelous structure of reality. It is enough if one tries merely to comprehend a little of this mystery every day. Never lose a holy curiosity.

      -Albert Einstein (1879 - 1955)

      Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.8e-fips-rhel5 DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635
      • 4310
      • 2,310 Posts
      Try =>
       WHERE `tdog`.`dog_id`=`'.$id.'`');
        • 24969
        • 120 Posts
        « MODx Parse Error »
        MODx encountered the following error while attempting to parse the requested resource:
        « Execution of a query to the database failed - Unknown column '1' in 'where clause' »
              SQL: SELECT `tdog`.`callname`, `tdog`.`regname` FROM `tbldogs` tdog WHERE `tdog`.`dog_id`=`1`
              [Copy SQL to ClipBoard]
         
        Parser timing
          MySQL: 	0.0089 s	(11 Requests)
          PHP: 	0.0624 s	 
          Total: 	0.0713 s


        That gives me the above error.
          The important thing is not to stop questioning. Curiosity has its own reason for existing. One cannot help but be in awe when he contemplates the mysteries of eternity, of life, of the marvelous structure of reality. It is enough if one tries merely to comprehend a little of this mystery every day. Never lose a holy curiosity.

          -Albert Einstein (1879 - 1955)

          Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.8e-fips-rhel5 DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635
          • 4310
          • 2,310 Posts
          Didn’t look at the whole code, only the $id variable shocked
          What is
          FROM `tbldogs` tdog
            • 24969
            • 120 Posts
            Didn’t look at the whole code, only the $id variable Shocked
            What is

            Yes... I am using a table alias.... it works in phpmyadmin... but not in modx!?!?
              The important thing is not to stop questioning. Curiosity has its own reason for existing. One cannot help but be in awe when he contemplates the mysteries of eternity, of life, of the marvelous structure of reality. It is enough if one tries merely to comprehend a little of this mystery every day. Never lose a holy curiosity.

              -Albert Einstein (1879 - 1955)

              Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.8e-fips-rhel5 DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635
              • 4310
              • 2,310 Posts
              If it’s just one table named tbldogs wouldn’t this work ?
              $rs=$modx->db->query('SELECT `callname`, `regname`
                   FROM `tbldogs` 
                   WHERE `dog_id`='.$id.'');
                • 24969
                • 120 Posts
                Thanks bunk58, there really was no need to alias the table, I was going to do some inner joins in the same query, but now I just want to get it working....
                  The important thing is not to stop questioning. Curiosity has its own reason for existing. One cannot help but be in awe when he contemplates the mysteries of eternity, of life, of the marvelous structure of reality. It is enough if one tries merely to comprehend a little of this mystery every day. Never lose a holy curiosity.

                  -Albert Einstein (1879 - 1955)

                  Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.8e-fips-rhel5 DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635
                  • 10487 MODX Staff
                  • 1,535 Posts
                  Quote from: bunk58 at Sep 14, 2009, 06:17 AM

                  Try =>
                   WHERE `tdog`.`dog_id`=`'.$id.'`');

                  That fix wasn’t far off, however it needs to be (minus the backticks on the ID value):
                   WHERE `tdog`.`dog_id`=' . $id);
                    Garry Nutting
                    Senior Developer
                    MODX, LLC

                    Email: [email protected]
                    Twitter: @garryn
                    Web: modx.com
                    • 24969
                    • 120 Posts
                    Thanks Gary,
                    I figured that part out, but I still cannot get it to display correctly... I would like it to display on a blank resource... the same one that called the page.

                    See I have a bunch of text on my page with some dropdown listboxes, the user selects the name of the dog they want to see a picture for, then it displays the pictures that are stored in the db.... but I cannot get the text to be removed.... sad
                      The important thing is not to stop questioning. Curiosity has its own reason for existing. One cannot help but be in awe when he contemplates the mysteries of eternity, of life, of the marvelous structure of reality. It is enough if one tries merely to comprehend a little of this mystery every day. Never lose a holy curiosity.

                      -Albert Einstein (1879 - 1955)

                      Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.8e-fips-rhel5 DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635
                      • 10487 MODX Staff
                      • 1,535 Posts
                      Hi rhyno, I’m not really sure how you’re trying to implement this - when the user selects a dog from the dropdown lists, are you wanting this to then load a second page that contains the image?

                      I don’t understand this part: " ... but I cannot get the text to be removed...."
                        Garry Nutting
                        Senior Developer
                        MODX, LLC

                        Email: [email protected]
                        Twitter: @garryn
                        Web: modx.com