I am trying to get data from database but the variable $dept is not working in query . the queries result1, result2 and result3 are not returning any results while result4 is working correctly. the variable $dept is also correct as when i print it's value it print (computer) but in query it's not working. help me please
<?php
if (isset($_POST['select_course'])) {
$dept = $_POST['department'];
$session = $_POST['session'];
$year = $_POST['year'];
$lab = $_POST['lab'];
$s_type = $_POST['s_type'];
$semester = $_POST['semester'];
$credit_h = $_POST['credit_h'];
$result1 = mysqli_query($con, "SELECT * FROM departments WHERE `name` = '$dept'");
$result2 = mysqli_query($con, "SELECT * FROM departments WHERE `name` = '".$dept."'");
$result3 = mysqli_query($con, "SELECT * FROM departments WHERE `name` =".mysqli_real_escape_string($dept));
$result4 = mysqli_query($con, "SELECT * FROM departments WHERE `name` = 'computer'");
while ($row = mysqli_fetch_array($result1)) {
echo $row['name'];
}
}
?>