I am trying to insert a date variable into a function to execute a mysql statement using it and retrieve a value from my database. However, the MySQL statement is executed and the date I am passing is correct, however, I am not getting the values I want back. Instead, I am getting nothing back. Here is the code in question:
<?php
function conn(){
$user = 'root';
$pass = '';
$db = 'proj';
$connection = mysqli_connect( "localhost", $user,$pass,$db);
if($connection){}
else{ die("Connection failed. Reason: ".mysqli_connect_error());}
return $connection;
}
function getRoom($dt){
$connection = conn();
$sql = "SELECT * FROM reservation WHERE Check_out = $dt";
$result = $connection->query($sql);
$row = mysqli_fetch_assoc($result);
$rn = $row['Room_Num'];
return $rn;
}
$date = '2017-03-25';
echo getRoom($date);