No problem. 🙂
Here's what's wrong:
You setup your connection on variable $dbh.
Until you call $dbh, it's just that...a variable.
In order to activate it, you would need to use it as a resource identifier
by calling your query like so:
mysql_query("SELECT * FROM table", $dbh);
That let's PHP know to preform the query with resource $dbh, which is your connection.
That just whats wrong and A method to fix it.
Now, I personally never have the need to connect to more than one server or database, so I usualy don't make my connection a variable
, for lack of better words.
What I generally do is just this:
includes.php
<?php
mysql_connect("localhost", "dbuser", "dbpass");
mysql_select_db("database");
?>
index.php
<?php
include('includes.php');
$stuff = mysql_query("SELECT stuff FROM table");
$iGotIt = mysql_fetch_array($stuff);
echo $iGotIt['stuff'];
?>
You may have noticed that I didnt use a resource identifier
on my query. That's becuase if you dont include one, than the last know database connection is used. Which happens to be in the include file.
Hope that makes some sense. 🙂