简体   繁体   English

我正在尝试使用android应用程序的php web servive从mysql db检索blob(image),但是blob列仍然为空。

[英]im trying to retrieve blob ( image ) from mysql db using php web servive for android app but the blob column still getting null

I am trying to retrieve blob ( image ) from mysql db using php web servive for android app but the blob column still getting null the insert code works fine but retrieve code return null even if the blob column is not empty how can i fix this ? 我正在尝试使用android应用程序的php web servive从mysql db检索blob(图像),但是blob列仍为null,插入代码可以正常工作,但是即使blob列不为空,检索代码也返回null,如何解决此问题?

      $result = mysql_query("SELECT * FROM core") or die(mysql_error());
        if (mysql_num_rows($result) > 0) {
            // looping through all results
            $response["articles"] = array();

            while ($row = mysql_fetch_array($result)) {
                // temp user array
                $product = array();
                $product["AID"] = $row["ID"];
                $product["ATitle"] = $row["title"];
                $product["ADate"] = $row["date"];   
                $product["AImage"]  = base64_encode($row["data"]);
               // $product["AImage"] =mysql_real_escape_string($b64img);
                $product["AArticle"] = $row["article"];

                // push single product into final response array
                array_push($response["articles"], $product);
            }
            // success
            $response["success"] = 1;


        }
        `

  //  insert part 
        ` 
            $base= $_POST['image'];
            $buffer = base64_decode($base);
            $buffer = mysql_real_escape_string($buffer);
            $sql ="INSERT INTO `core`(`title`,`date`,`article`,`image`)VALUES ('$title','$date','$article','$buffer')";`

easy ... 简单 ...

This is incorrect ... 这是不正确的...

$product["AImage"] = base64_encode($row["data"]);

This is correct ... 这是对的 ...

$product["AImage"] = base64_encode($row["image"]);

You were selecting data when it should be image 你选择data时,它应该是image

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM