dongpa3109 2019-06-30 20:14
浏览 32

比较从sql server数据库问题中检索到的php中的字符串

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:

  1. get the fingerprint data.
  2. encode it into BASE64 String.
  3. 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

  4. 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.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度
    • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测