title: wordpress include a second mysql connection
body: <p>I have a website with some pages, now to add other pages I've installed wordpress  in a subdirectory.</p>
  
  <p>I've created a CHILD THEME for wordpress. In the header.php of my child theme I've included the home.css and the header markup of my main website. All ok!</p>
  
  <p>Because my <strong>main website</strong> already has a connection to a mysql db (not the wp one), i was thinking to add a this mysql connection in the header.php of my child theme too.</p>
  
  <p>So I've added this code as first thing on the header.php of my child theme:</p>
  
  <pre><code>function example( $value ) {
  global $con;
  return mysqli_real_escape_string( $con, trim( $value ) );
  }
  
  $con = mysqli_connect( HOST, USER, PASS, DB ) or die( 'Error' );
  
  $test = example( 'my string' );
  </code></pre>
  
  <p>While the exact same code work on my main website, in wordpress i get this error:</p>
  
  <pre><code>Warning: mysqli_real_escape_string() expects parameter 1 to be mysqli, null given in /home/user/public_html/wordpress/wp-content/themes/afs/header.php on line 11
  </code></pre>
  
  <p>PS: I think the problem is in the <strong>global $con</strong>, because if I pass <strong>$con as function argument</strong> everything works.</p>
  
  <p>It's possibile to add a second mysql connection in my wordpress child theme unsing <strong>global $con</strong> or should I change all my php functions? I'm curious to understand why this happens..</p>