title: Calling a db connection inside a class
body: <p>I have a problem regarding my mysql connection. I need to access the connection inside a class. How do I do it? Even if I try to include the connection file, or the connection variable $con0 inside the class, it has no value so I get an error.</p>
  
  <p>Connection.php</p>
  
  <pre><code>&lt;?php
  $username = " ";
  $password = "";
  $hostname = " ";    
  $con = mysql_connect()
  ?&gt;
  </code></pre>
  
  <p>model.php</p>
  
  <pre><code>&lt;?php
  
  include(connection.php);
  class model{
  
  function needTheConnection($uid){
  $q = "SELECT x from  DB.table WHERE id = '" . $uid . "'";
  $res  = mysql_query($q);
  }
  
  }
  ?&gt;
  </code></pre>
  
  <p>This gives me the "mysql_query(): supplied argument is not a valid MySQL-Link resource".</p>
  
  <p>What is wrong?</p>
  
  <p>Thanks,
  tinks</p>