We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10076
    • 1,024 Posts
    hi , I am trying to upgrade a site to Revo. everything seems to work except for the core bit of that site, A database containing adres etc data.I get the error "No database selected". I gues it s in lines like:
    "global $modx;". Here s the part of the snippet that should start the connection to the data. Maybe a hint on what should change here?

    <img src=\"[[++site_url]]assets/snippets/nbscripts/images/details.png\" class=\"icon\" alt=\"Vieuw $lname 's details\" title=\"Vieuw $name 's details\" style=\"border:0\"></a>";
    
    
    if ($email ==!'') { 
    	echo "<a href=\"mailto:$email\">
    	<img src=\"[[++site_url]]assets/snippets/nbscripts/images/email.png\" class=\"icon\" alt=\"Email $name\" title=\"Email $name\" style=\"border:0\"></a>";
    }
    
    if (isset($_SESSION['webInternalKey'])) { global $modx;
      // User logged in so show icon
    echo"
    
    <a href=\"/index.php?id=".$idcompmod."&idcomp=".$idcomp."&compchar=".$compchar."\">
    <img src=\"[[++site_url]]assets/snippets/nbscripts/images/edit.png\" class=\"icon\" alt=\"Edit $name 's details\" title=\"Edit $name 's details\" style=\"border:0\"></a>";}
    else {
      // user not logged in
    }
    
    if (isset($_SESSION['webInternalKey'])) { global $modx;
      // User logged in so show icon
    
    echo"
    <a href=\"/index.php?id=".$idcdelete."&idcomp=".$idcomp."&compchar=".$compchar."&abbreviation=".$abbreviation."\">
    <img src=\"[[++site_url]]assets/snippets/nbscripts/images/delete.png\" class=\"icon\" alt=\"Delete $name\" title=\"Delete $name\" style=\"border:0\"></a></td>";}
    else {
      // user not logged in
    }
    echo "    </tr>";
    echo "    </tr>";
    }
      echo "        </tbody></table>";
    }
    
    
    • Hello,

      First off you do realize you can't directly upgrade Evo > Revo, also any snippets/plugins will need to be rewritten for Revo as it's a totally new environment?

      That being said, what is the snippet in question attempting to do?
        Patrick | Server Wrangler
        About Me: Website | TweetsMODX Hosting
        • 10076
        • 1,024 Posts
        Hi AMD off course, site runs well in EVO, but it s a voluntary site and I found MODX ers who want to volunteer but they know REVO. I used "Provisioner" to migrate to REVO and all the code has been transfered well. Its just the custom snippets (not all done by me) that show problems. So what do you think?

        BTW this forum looks horrible in IE9.
          • 10076
          • 1,024 Posts
          Sorry did not see the last question, check pianoquartet.nl go to the composer menu item. Now that is in EVO. On my local REVO install as soon as I click a letter in the leter choice, I get the above error. SO MODX is connecting, just the scripts are not.
          • In short it sounds like you need to hire a developer to rewrite the snippet providing that functionality. You may be able to use rowboat to mimic some of the functionality in the mean time.

            Revo is a total rewrite of Evo so in a manner of speaking you need to start fresh if you have any custom code. My suggestion would be to keep the site in Evo if it's working for you. It's not that hard to learn/use Evo...
              Patrick | Server Wrangler
              About Me: Website | TweetsMODX Hosting
              • 3749
              • 24,544 Posts
              If a snippet is not too long, you can always post it here and ask for tips on rewriting it for Revolution.


              ------------------------------------------------------------------------------------------
              PLEASE, PLEASE specify the version of MODX you are using.
              MODX info for everyone: http://bobsguides.com/modx.html
                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
                • 10076
                • 1,024 Posts
                **edit, only just noticed this is not the correct script. So I now pasted the script that runs on the EVO site and flawlessly spits out the list of the letter that was choosen. It s almost all "normal" PHP code.
                And gives the no database selected error if i make a letter choice. Guess I ll stick with EVO.

                @AMDBuilder, I know EVO (and REVO) are intuitive enough. It s just that the volunteers I found prefer to work with REVO. Also we re planning to rewrite the snippets to integrate in MODx because that will open loads of options that will be very handy. So, smarter (I think) to migrate to REVO first

                @BobRay, the above code is the most important bit of the snippet that connects to the db.
                It is plane PHP code with a few MODx "fragments" inside.
                It calls externall PHP scripts diplaying what you see on the site mentioned above.
                Find the complete snippet below, Frank.

                <?php
                $idcompdetails = 17;
                $idcdelete	= 74;
                $idcompmod     = 18;
                $idcomp  = $_GET['idcomp'];
                $compchar      = $_GET['compchar'];
                
                if (strlen($compchar) > 0)
                {
                
                   $select_subset = true;
                
                   $letter = strtoupper(substr($compchar,0,1));
                
                   if (is_numeric($letter))
                
                      $first_is_number = true;
                
                   else $first_is_number = false;
                
                }
                
                else $select_subset = false;
                
                
                
                //@mysql_query("SET NAMES 'iso-8859-1'");
                //@mysql_query('SET COLLATION_CONNECTION=@@collation_database');
                
                
                //$result = mysql_query($sql) or die('ERROR: '.$query.' '.mysql_error()); 
                
                $letterlinks = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; 
                
                
                
                /*echo '<a Composer="top"></a>'; */
                
                echo '<a href="index.php?id=2&compchar=0">0-9</a> '; 
                
                for ($i = 0; $i < 26; $i++): 
                
                echo '<a href="index.php?id=2&compchar='.$letterlinks[$i].'">'.$letterlinks[$i].'</a> '; 
                
                endfor; 
                
                
                
                
                
                
                
                //echo "
                select_subset = " . $select_subset;
                
                
                
                if ($select_subset)
                
                {
                
                // 001: Database query
                
                
                
                  if ($first_is_number)
                
                     $query = "select * from quartets WHERE lname >= '0%' and lname <= '9%'";
                
                  else $query = "select * from quartets WHERE lname like '".$compchar."%'";
                
                
                
                  $query .= " order by lname ASC";
                
                
                
                //echo "
                query = " . $query;
                
                
                
                // 002: Execute query
                
                
                
                  $res = mysql_query($query);
                
                
                
                  if (!$res)
                
                  {
                
                     die ('Could not run query: ' . mysql_error());
                
                  }
                
                
                
                  echo "
                
                ";
                
                
                echo "   <table border=\"0\" align=\"left\" width=\"680\"valign=\"left\" color=\"#fafafa\" cellpadding=\"10\" cellspacing=\"2\">";
                
                
                
                
                
                echo "    <thead>";
                echo "    <tr>";
                echo "      <th scope=\"row\" bgcolor=\"#cccccc\">Last Name</th>";
                echo "      <th scope=\"row\" bgcolor=\"#cccccc\">First Name</th>";
                echo "      <th scope=\"row\" bgcolor=\"#cccccc\">Composition</th>";
                echo "      <th scope=\"row\" bgcolor=\"#cccccc\">Options</th>";
                echo "    </tr>";
                echo "    </thead>";
                
                
                echo "    <tbody>";
                
                
                $i = 0;
                  while ($row = mysql_fetch_array($res, MYSQL_BOTH))
                  while ($row = mysql_fetch_array($res, MYSQL_BOTH)) 
                
                  {
                
                
                
                    $idcomp      = $row[0];
                    $Opus         = $row[4];
                    $lname  = $row[8];
                    $fname  = $row[7];
                    $information = $row[9];
                
                
                
                echo "    <tr>";
                {
                echo "
                ";
                if($i%2 == 0)
                {
                echo "<tr bgcolor='#F4F6FA'>";
                $i++;
                }
                else
                {
                echo "<tr bgcolor='#E9EDF5'>";
                $i++;
                }
                }
                
                echo "      <td >".$lname."</td>";
                echo "      <td >".$fname."</td>";
                echo "      <td >".$Opus."</td>";
                echo "      <td ><a href=\"/index.php?id=".$idcompdetails."&idcomp=".$idcomp."&compchar=".$compchar."\">
                <img src=\"http://www.pianoquartet.nl/assets/snippets/nbscripts/images/details.png\" class=\"icon\" alt=\"Vieuw $lname 's details\" title=\"Vieuw $name 's details\" style=\"border:0\"></a>";
                
                
                if ($email ==!'') { 
                	echo "<a href=\"mailto:$email\">
                	<img src=\"http://www.pianoquartet.nl/assets/snippets/nbscripts/images/email.png\" class=\"icon\" alt=\"Email $name\" title=\"Email $name\" style=\"border:0\"></a>";
                }
                
                if (isset($_SESSION['webInternalKey'])) { global $modx;
                  // User logged in so show icon
                echo"
                
                <a href=\"/index.php?id=".$idcompmod."&idcomp=".$idcomp."&compchar=".$compchar."\">
                <img src=\"http://www.pianoquartet.nl/assets/snippets/nbscripts/images/edit.png\" class=\"icon\" alt=\"Edit $name 's details\" title=\"Edit $name 's details\" style=\"border:0\"></a>";}
                else {
                  // user not logged in
                }
                
                if (isset($_SESSION['webInternalKey'])) { global $modx;
                  // User logged in so show icon
                
                echo"
                <a href=\"/index.php?id=".$idcdelete."&idcomp=".$idcomp."&compchar=".$compchar."&abbreviation=".$abbreviation."\">
                <img src=\"http://www.pianoquartet.nl/assets/snippets/nbscripts/images/delete.png\" class=\"icon\" alt=\"Delete $name\" title=\"Delete $name\" style=\"border:0\"></a></td>";}
                else {
                  // user not logged in
                }
                echo "    </tr>";
                echo "    </tr>";
                
                
                }
                
                
                
                  echo "        </tbody></table>";
                
                }
                
                //mysql_close($sqlConn);
                ?>
                


                MODX Revolution 2.2.0-pl2 (traditional) [ed. note: franklos last edited this post 12 years ago.]
                  • 6228
                  • 249 Posts
                  It's likely a moot point at this time, but that script can rather easily be updated to run in Revo using native PDO. You can even keep your SQL query string intact (without breaking it down into xPDO method calls).
                    lo9on.com

                    MODx Evolution/Revolution | Remote Desktop Training | Development
                    • 10076
                    • 1,024 Posts
                    Okay, als in the future I would like to see the site in Revo. What s the solution?
                      • 2912
                      • 315 Posts
                      Hi Frank,

                      You have the following line in twice:

                      while ($row = mysql_fetch_array($res, MYSQL_BOTH))


                      Not sure if it's not helping or not. I'm not into Revo yet although I did install it on my dev machine. As it's new and using xPDO I don't think it connects to a database in the native way that EVO did.

                      After making a simple snippet to issue mysql_connect and mysql_select_db commands I managed to get data out of a table.

                      Maybe it will help.

                      Sorry to everyone, I know this is not the way to do things.
                        BBloke