我正在尝试从我的 api 编码中获得响应,但即使代码为真,它也不会返回任何结果
这是我的代码
<?php
include "connect.php";
function api($id, $token, $to) {
$result=$conn->prepare('select * from users where id=:user');
$result->bindParam(':user', $id);
$result->execute();
while($row = $result->fetch(PDO::FETCH_BOTH))
{
$username=$row['username'];
$credit=$row['balance'];
$pin=$row['pin'];
}
$sj = $conn->prepare("SELECT number FROM users WHERE number = :number");
$sj->bindParam(":number", $to);
$sj->execute();
if($sj->rowCount()<1){
$a=array('code'=>'0', 'text'=>'not working');
return json_encode($a);
}
elseif($token ==$pin)
{
$a=array('code'=>'10', 'text'=>'not working');
return json_encode($a);
}
else {
$a=array('code'=>'1', 'text'=>'ok');
return json_encode($a);
}
}
$id=$_GET['id'];
$token=$_GET['token'];
$to=$_GET['to'];
$a=api($id, $token, $to);
echo $a;
?>