I am using SQL Server Database, where one of my table has a column type VARCHAR(MAX). In this column I am storing the BASE64 string.
Basically the flow of the app is:
- get the fingerprint data.
- encode it into BASE64 String.
-
Store it to the sql server database using PHP by checking its existence
3a. Retrieve all the fingerprints from the database
3b. check the to be inserted fingerprint data with all fingerprints received from the database
3c. if any fingerprint matches with it , then return false if any fingerprint does not match with it, return true
-
if return value is true , then insert the fingerprint with following query , if false then show error.
INSERT INTO EMPTABLE ( Finger_Data ) values ( CONVERT( VARCHAR(MAX) , $Finger_Data ) )
To get and check the fingerprints at step no 3, the following code is used.
$sqlString = "SELECT CAST( Finger_Data AS VARCHAR(MAX)) AS FINGER FROM
EMPTABLE ";
$stmt = $this->conn->prepare($sqlString);
$stmt->execute();
$data = $stmt->fetchAll();
if ($stmt->rowCount() > 0) {
if ($data) {
foreach ($data as $row) {
$found = false;
if ($Finger_Data === $row['FINGER']){
echo "
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Duplicate found <<<<<<<<<<<<<<<< \
$found = true;
}
if($found){
echo "
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Implementing found <<<<<<<<<<<<<<<< \
}
}
}
}
Here my question is, I am not be able to compare these two strings at all. When I print those two variables, I see them 80 percent equals while other part of the string is not matching. However when I directly check in database the data shows correctly, that means reading in PHP or writing from matters.