I am new to mysqli. I am connecting to a mysql db, and fetching some data.
$user_id = "CCD_00005";
/* create a prepared statement */
if ($stmt = mysqli_prepare($GLOBALS['conn'], "SELECT user_name FROM user_master WHERE user_id=?")) {
/* bind parameters for markers */
mysqli_stmt_bind_param($stmt, "s", $user_id);
/* execute query */
mysqli_stmt_execute($stmt);
/* bind result variables */
mysqli_stmt_bind_result($stmt, $user_name);
/* fetch value */
mysqli_stmt_fetch($stmt);
echo("Total Results:".$stmt->num_rows."<br />");
printf("%s is having name %s\n", $user_id, $user_name);
/* close statement */
mysqli_stmt_close($stmt);
}
I am getting the result Total Results:0
CCD_00005 is having name sdafasdf
Why am I not getting the row count as 1.
Please help.