I have a table with only one row called users in my database with email and mobile_number as it's columns.My row has that mobile_number column value as 9866163987.When I am trying to select this mobile number value my prepared statement is returning 0 rows.Here is my code.
if($this->checkExists("email",$_POST["registerEmail"]))
{
--some code--
}
if($this->checkExists("mobile_number",$_POST["registerMobileNumber"]))
{
--some code--
}
private function checkExists($field,$value)
{
include("includes/connection.php");
$sql = "SELECT $field FROM users WHERE $field=:value";
$prepare = $connection->prepare($sql);
$prepare->bindParam(":value",$value,PDO::PARAM_STR);
try
{
$prepare->execute();
}
catch(PDOException $e)
{
die($e->getMessage());
}
$count = count($prepare->fetchAll());
echo $count."<br />";
if($count == 1)
{
return true;
}
else
{
return false;
}
}
For email it is working fine and returning one row,but for mobile_number it is returning 0 rows?what to do?