PHP include/require variables not passed
<p>EDIT: SOLVED</p>

<p>I'm trying to pass some variables for a mysql connection from a separate file. However, they seem to only be coming through in a string and not as variables.</p>

<p>connect.php:</p>

<pre><code>&lt;?php
    function connect(){
        require ($_SERVER['DOCUMENT_ROOT'].'/db-connect.php');
        $conn1 = new mysqli($servername, $username, $password, $dbname);
        if ($conn1-&gt;connect_error) {
            die("Connection failed: " . $conn1-&gt;connect_error);
            }
            echo $conn1-&gt;host_info . "\n";
    }
    connect();
?&gt;
</code></pre>

<p>db-connect.php:</p>

<pre><code>&lt;?php
$servername = "localhost";
$username = "-";
$password = "--";
$dbname = "---";
?&gt;
</code></pre>

<p>Message coming through:</p>

<pre><code>$servername = "localhost"; $username = "-"; $password = "--"; $dbname = "---";Connection failed: Access denied for user '-'@'localhost' (using password: NO)
</code></pre>

<p>notes:
The $password at the end is different that what is in the db-connect.php file. It is an older password that I used to have when I first tried it. Also, the user '-'@'localhost' is an old user and not the user from $username.</p>

<p>Any ideas please and thanks?
Matt</p>