viewing a column in mysql database using php script I'm trying to print a row from a table in mysql using a PHP script - here is the code but its not working - it shows Bad query apparently there is no issue:

$conn = mysqli_connect($servername, $username, $password, $db);
if (!$conn) {
   die("Connection failed: " . mysqli_connect_error());
}

else{

echo "Connected successfully";

}


$any = "show columns from help_category";
$chk = mysqli_query($any) or die("Bad Query: $sql");
echo"&lt;table border='3'&gt;";
echo"&lt;tr&gt;&lt;td&gt;Type&lt;/td&gt;&lt;tr&gt;";

while($row = mysqli_fetch_assoc($chk))

{

echo"&lt;tr&gt;&lt;td&gt;{$row['Type']}&lt;/td&gt;&lt;tr&gt;";


}


echo"&lt;/table&gt;";
I have checked your code and i found out that you have issue with your query execution on php function mysqli_query

mysqli_query requires two parameter first one is connection object and second one is query variable to execute a query.

Below is exact code:-

$conn = mysqli_connect($servername, $username, $password, $db);
if (!$conn) {
   die("Connection failed: " . mysqli_connect_error());
}

else{

echo "Connected successfully";

}


$any = "show columns from transaction";
$chk = mysqli_query($conn, $any) or die("Bad Query: $sql");
echo"&lt;table border='3'&gt;";
echo"&lt;tr&gt;&lt;td&gt;Type&lt;/td&gt;&lt;tr&gt;";

while($row = mysqli_fetch_assoc($chk))

{

echo"&lt;tr&gt;&lt;td&gt;{$row['Type']}&lt;/td&gt;&lt;tr&gt;";


}


echo"&lt;/table&gt;";