title: Connection to second database in wordpress
body: <p>I want to connect to an external database in Wordpress for a custom script.
  But when I run the script it stops after  </p>
  
  <p>The connection is good it is tested by the plugin Ari Adminer. This plugin also vallidates the excistence of the tables and fields.</p>
  
  <p>Wordpressversion = 4.9.4</p>
  
  <p>This is part of the script:</p>
  
  <pre><code>&lt;?php
  $mydb = new wpdb('user','password','database','localhost');
  $urlfoto = $url.'images/logos/';
  ?&gt;
      &lt;div class="klanten_gallery"&gt;
          &lt;div class="container"&gt;
              &lt;div class="klanten_gallery_inn"&gt;
                  &lt;div class="klanten_gallery_header"&gt;
                  Onze klanten
                  &lt;h2&gt;&lt;?php the_title(); ?&gt;&lt;/h2&gt;
                      &lt;div class="border_photo_klanten"&gt;&lt;/div&gt;
                  &lt;/div&gt;
                  &lt;div class="klanten_gallery_text"&gt;
                      &lt;?php
                          if ( have_posts() ) : while ( have_posts() ) : the_post(); 
                              the_content(); 
                          endwhile; endif;
                      ?&gt;
                  &lt;/div&gt;
                  &lt;div class="gal"&gt;
                  &lt;?php   
      $qry ='
          SELECT kl_logos.id, kl_logos.klnr, kl_logos.image, kl_overzicht.kl_overzicht_naam
          FROM kl_logos
          INNER JOIN kl_overzicht
          ON kl_logos.klnr = kl_overzicht.kl_overzicht_klnr
          ORDER BY RAND()
          LIMIT 18';
      if(!$result = $mydb -&gt;query($qry)) {
          echo ' Error in query: '. $mydb-&gt;error; 
      }else while($list = $result-&gt;fetch_assoc()){
          echo'
                  &lt;a class="fancy6" href="#" title="'.$list['kl_overzicht_naam'].'"&gt;
                      &lt;div class="klanten_image"&gt;
                      &lt;img src="'.$urlfoto.$list['image'].'" alt="'.$list['kl_overzicht_naam'].'"/&gt;
                      &lt;/div&gt;
                  &lt;/a&gt;';
                  }       
      ?&gt;      
                   &lt;/div&gt; 
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  </code></pre>