SQL not working unless multiple db_connect(); statements
<p>In the past I've had no issues using one simple:</p>

<p>$link = db_connect();</p>

<p>in a single file with multiple SQL commands like so:</p>

<pre><code>$sql = "UPDATE table SET...";

$sql_result = mysql_query($sql, $link)
or die("Couldn't execute query.");

$sql2 = "UPDATE table2 SET...";

$sql_result2 = mysql_query($sql2, $link)
or die("Couldn't execute query.");
</code></pre>

<p>Now any new file I create won't work without multiple/separate db_connects.  For example:</p>

<pre><code>$link = db_connect();

$link2 = db_connect();

$sql = "UPDATE table SET...";

$sql_result = mysql_query($sql, $link)
or die("Couldn't execute query.");

$sql2 = "UPDATE table2 SET...";

$sql_result2 = mysql_query($sql2, $link2)
or die("Couldn't execute query.");
</code></pre>

<p>The old files with multiple mysql_queries referencing a single db_connect(); are still working fine.  What could have changed?</p>

<p>Thanks.</p>

<p>Updated to include the db_connect(); function:</p>

<pre><code>function db_connect($db="database", $host="localhost", $user="user", $p="password") {

    $dbcnx = @mysql_connect($host, $user, $p);

    if (!$dbcnx)
    {
    echo( "&lt;p&gt;Unable to connect to the database server at this time.&lt;/p&gt;" );
    exit();
    }

    $database = @mysql_select_db($db, $dbcnx);
    if (!$db)
    {
    echo "&lt;p&gt;Unable to locate the database at this time.&lt;/p&gt;";
    exit();
    }

return $dbcnx;
}
</code></pre>
