PHP json_encode无法与ibase一起使用

时间:2018-09-18 15:00:35

标签: php json

我的代码中的一部分

$blstkodu = $row[1];

  $sqlisimcek = "select * from STOK where blkodu='$blstkodu'";
  $queryisimcek = ibase_prepare($sqlisimcek);
  $rsisimcek = ibase_execute($queryisimcek);
  $rowisimcek = ibase_fetch_row($rsisimcek);

  $stok_adi = $rowisimcek[2];


  $sql2 = "select * from STOK_FIYAT where blstkodu='$blstkodu' and alis_satis='2' and fiyat_no='1'";
  $query2 =  ibase_prepare($sql2);
  $rs2=ibase_execute($query2);
  $row2 = ibase_fetch_row($rs2);

  $fiyati = $row2[6];
  $hesap = $row2[4];



  $sonuc->stok_adi = $stok_adi;
  $sonuc->fiyati = $fiyati;
  $sonuc->hesap = $hesap;
  echo json_encode($sonuc);

这不起作用,因为我正在使用json_encode,但是当我更改为echo时,它可以正常工作。我该如何解决。

如果我使用的是MySQL数据库,则我的代码可以正常工作。但它不适用于ibase,请帮助我,谢谢。作品对此进行编码;

 $blkodu = $row['blkodu'];

        $sql2 = "SELECT fiyati,hesap FROM stok_fiyat WHERE blstkodu = '$blkodu' and alis_satis='2' and fiyat_no='1'";

        $result2 = mysqli_query($con,$sql2);

        $row2 = mysqli_fetch_array($result2,MYSQLI_ASSOC);


        $fiyati = $row2['fiyati'];
        $hesap = $row2['hesap'];

        $sonuc->stok_adi = $stok_adi;
        $sonuc->fiyati = $fiyati;
        $sonuc->hesap = $hesap;



      echo json_encode( $sonuc);

1 个答案:

答案 0 :(得分:0)

  if ($db = ibase_connect('database.FDB', 'username', 'password','utf8')) 

如果您在连接字符串中添加UTF 8,则一切正常,谢谢大家