首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我正在尝试使用php web servive for android app从mysql数据库中检索blob (图像),但blob列仍然为空

问我正在尝试使用php web servive for android app从mysql数据库中检索blob (图像),但blob列仍然为空
EN

Stack Overflow用户
提问于 2014-10-23 22:19:43
回答 1查看 583关注 0票数 0

我正在尝试使用php web servive for android app从mysql数据库中检索blob ( image ),但blob列仍然为null插入代码工作正常,但检索代码返回null,即使blob列不为空,我如何解决这个问题?

代码语言:javascript
复制
      $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')";`
EN

回答 1

Stack Overflow用户

发布于 2014-10-23 22:38:01

简单..。

这是不正确的。

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

这是正确的..。

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

您在应该为image的情况下选择了data

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26530271

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档