Undefined variable error when fetching data from MySQL <p>I get an error when fetching data from a MySQL database using PHP.</p> <pre><code>Undefined variable: result in C:\wamp\www\mbdb\Biomarkerresult1.php on line 20 mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given in C:\wamp\www\mbdb\Biomarkerresult1.php on line 20 </code></pre> <p>My dropdown list coding:</p> <pre><code>&lt;select name="names" value="name"&gt; &lt;option value="Biomarker"&gt;Select a Biomarker&lt;/option&gt; &lt;option value="Diagnostic"&gt;Diagnostic&lt;/option&gt; &lt;option value="Prognsotic"&gt;Prognostic&lt;/option&gt; &lt;option value="Predictive"&gt;Predictive&lt;/option&gt; </code></pre> <p>Here is displaying data:</p> <pre><code>&lt;?php $con=mysqli_connect('localhost','root','','mbdb'); if(mysqli_errno($con)) { echo "Can't Connect to mySQL:".mysqli_connect_error(); } if(isset($_POST['names'])) { $name = $_POST['names']; $fetch="SELECT * FROM metabolites WHERE Biomarker_Category = '".$name."'"; $result = mysqli_query($con,$fetch); } while($row=mysqli_fetch_array($result)) { //----- } </code></pre> <p>Can anyone help me with this?</p>