I am using MySQLi Prepared statements using PHP.
The code I have written is:
<?php
  function mySQLi_connection(){
    $hostName = "localhost";
    $userName = "admin";
    $password = "admin";
    $databaseName = "db_name";
    mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
    $mysqli = new mysqli($hostName, $userName, $password, $databaseName);
    if($mysqli->connect_errno > 0){
        die('Unable to connect to database [' . $db->connect_error . ']');
    }
    return $mysqli;
}
function getEmpNamebyID($id){
    $empname = NULL;
    $mysqli = mySQLi_connection();
    $stmt = $mysqli->prepare("SELECT `empname` FROM `employee_details` WHERE `EMP_ID` =?");
    $stmt->bind_param('s', $id);
    $stmt->execute();
    $stmt->bind_result($empname);
    echo $empname;
    return $empname;
}
echo getEmpNamebyID(95);
?>
The function getEmpNamebyID() DOES NOT return any result from the database. Even though the query is OK with the value 95.
I wonder if there is anything wrong with my Prepare Statements. The Connection is working fine.
 
    