I have a table bank
as follows:
|name|day|time|
|jack| 1 | 2 |
I need to check for name
, day
and time
. Now, even if I change values of WHERE
condition parameters, such that no matching rows are found, it still prints "success". What could be wrong here ? Below if my code attempt:
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "test";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT * FROM `bank` WHERE name='jack' AND day='1' AND time='2'";
$result = $conn->query($sql);
if ($result)
{
echo "success";
}
else
{
echo "0 results";
}
$conn->close();
?>