title: mysql_connect issues, resource type 'Unknown'
body: <p>I am having a problem when trying to access some functions in my mysql class. The function I have to connect to my database is as follows:</p>
  
  <pre><code>function connect_DB() {
      $this-&gt;connection = mysql_connect($this-&gt;dbURL, $this-&gt;dbUser, $this-&gt;dbPass) or trigger_error('Connection failed: ' . mysql_error($connection), E_USER_ERROR);
      $this-&gt;db = mysql_select_db($this-&gt;dbName, $this-&gt;connection) or trigger_error('Database selection failed: ' . mysql_error($db), E_USER_ERROR);
  }
  </code></pre>
  
  <p>And I create my mysql object using this:</p>
  
  <pre><code>$dbConf = new StoreConfDB();
  $dbConf-&gt;connect_DB();
  </code></pre>
  
  <p>Now I have a function that is supposed to grab all of the column names from a specified table. Code:</p>
  
  <pre><code>function get_db_columns($table) {
  global $dbConf;
  print_r($dbConf-&gt;get_db());
  $result = $dbConf-&gt;query_DB_resource('SELECT * FROM ' . $table);
  for($i = 0; $i &lt; mysql_num_fields($result); $i++) {
      $meta = mysql_fetch_field($result, $i);
      $fields[] = $meta-&gt;name;
  }
  mysql_free_result($result);
  return $fields;
  }
  </code></pre>
  
  <p>But I am getting errors, such as: </p>
  
  <pre><code>Warning: mysql_query(): 5 is not a valid MySQL-Link resource
  </code></pre>
  
  <p>And if I try to remove the connection argument from the mysql_query call I get this: </p>
  
  <pre><code>Notice: Could not run query: No database selected in ...
  </code></pre>
  
  <p>Now I am running a debugger and have pinpointed what the problem is (I think). When the class works, the connection variable is set to: <code>resource id='5' type='mysql link'</code></p>
  
  <p>But when it calls the query function in the mysql class from inside the <code>get_db_columns()</code> function the connection variable is: <code>resource id='5' type='Unknown'</code></p>
  
  <p>So somehow the connection variable gets messed up even though both of the connection variables should be the same thing? (from <code>$dbConf</code>)? I've tested this function in 2 different places, it works in one and not the other! Please help!</p>
  
  <p>@footy:</p>
  
  <p>A print_r on $dbConf returns:</p>
  
  <pre><code>StoreConfDB Object ( [dbURL] =&gt; localhost [dbUser] =&gt; root [dbPass] =&gt; [dbName] =&gt; db1 [connection] =&gt; Resource id #5 [db] =&gt; 1 )
  </code></pre>
  
  <p>The query_DB_resource function:</p>
  
  <pre><code>function query_DB_resource($query) {
      $sql_query = mysql_query($query) or trigger_error('Could not run query: '. mysql_error());
      return $sql_query;
  }
  </code></pre>