PHP DB Connection question
<p>I am getting the error: </p>

<blockquote>
  <p>Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in /home/mjcrawle/public_html/home/index.php on line 23</p>
</blockquote>

<p>Line 23 turns out to be <code>$num_results = mysqli_num_rows($result);</code> but I am thinking the error is further up but I am having trouble finding it.</p>

<p>The actual code that I am using to connect to the DB is (I do understand there is a redundancy if the database cannot connect):</p>

<p>Any help would be wonderful and a reason for the error would be awesome!</p>

<pre><code>/*Connect To DB*/
$conn = mysqli_connect($host, $user, $pwd)
        or die("Could not connect: " . mysql_error()); //connect to server
    mysqli_select_db($conn, $database)
        or die("Error: Could not connect to the database: " . mysql_error());

    /*Check for Connection*/
    if(mysqli_connect_errno()){
        /*Display Error message if fails*/
        echo 'Error, could not connect to the database please try again later.';
    exit();
    }
/*Querry for states*/
$query = "SELECT StateAbbreviation, StateName, FROM USState ORDER BY StateName";
$result = mysqli_query($conn, $query);
$num_results = mysqli_num_rows($result);
?&gt;
</code></pre>
