Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/performance/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Json 如果条件正确,为什么我总是得到零_Json_Swift_Parsing - Fatal编程技术网

Json 如果条件正确,为什么我总是得到零

Json 如果条件正确,为什么我总是得到零,json,swift,parsing,Json,Swift,Parsing,在条件成功后,我不断得到零和错误 我有这个PHP <?php require_once 'hehe'; error_reporting(0); $sql = "SELECT Precio FROM Solicitudes where ID_Pasajero = '".$_POST['ID_Pasajero']."' and Estado = '1' ORDER BY ID_Solicitudes DESC LIMIT 1"; $result = $conexion->query($s

在条件成功后,我不断得到零和错误

我有这个PHP

<?php
require_once 'hehe';
error_reporting(0);
$sql = "SELECT Precio FROM Solicitudes where ID_Pasajero = '".$_POST['ID_Pasajero']."' and Estado = '1' ORDER BY ID_Solicitudes DESC LIMIT 1";
$result = $conexion->query($sql);
if ($result->num_rows > 0) {
    $count = $result->num_rows;
    $row = mysqli_fetch_array($result);
    echo '{
    "Response":"true",
    "Perfil":[{
        "Precio":"'.$row['0'].'"
    }]
}';

}else{
    echo '{
    "Response":"false",
    "Perfil":[{
        "Precio":"false"
    }]
}';
}


mysqli_close($conexion);
?>
我假装用这个代码做的是定时器

self.helloWorldTimer = Timer.scheduledTimer(timeInterval: 15.0, target: self, selector: #selector(UnaVezLogeadoViewController.ConsultarSiAcepto), userInfo: nil, repeats: true)
它会询问驱动程序是否已经接受了请求,因此每隔15秒代码就会将此PHP发送到我的数据库

我不知道缺少了什么,因为我从控制台得到了这个响应

esperando a que el conductor envie la cotizacion...
esperando a que el conductor envie la cotizacion...
96 bytes
Optional(<NSHTTPURLResponse: 0x16790b30> { URL:     hehe } {    status code: 200, headers {
"Content-Encoding" = gzip;
"Content-Type" = "text/html; charset=UTF-8";
Date = "Fri, 11 Jan 2019 23:51:59 GMT";
Server = Apache;
"x-powered-by" = "PHP/7.1.25";
 } })
el conductor acepto el viaje.. enviando cotizacion
nil
error hapend :0
因此,它的工作暂停

if blog.Response == "false" {

                    print("esperando a que el conductor envie la cotizacion...")

                }
正如您所看到的,代码获得了正确的值

96 bytes
Optional(<NSHTTPURLResponse: 0x16790b30> { URL:     hehe } {    status code: 200, headers {
"Content-Encoding" = gzip;
"Content-Type" = "text/html; charset=UTF-8";
Date = "Fri, 11 Jan 2019 23:51:59 GMT";
Server = Apache;
"x-powered-by" = "PHP/7.1.25";
 } })
el conductor acepto el viaje.. enviando cotizacion
编写代码时,信息填写正确 我没有在屏幕或函数上得到任何错误,我只是因为那个错误而无法继续,我能避免吗

我尝试过多次用不同的方法更改我的PHP,以更改我的JSON响应并避免出现此零错误

我做了一个不同的VC,它默认启动函数,现在可以工作了

if blog.Response == "false" {

                    print("esperando a que el conductor envie la cotizacion...")

                }
96 bytes
Optional(<NSHTTPURLResponse: 0x16790b30> { URL:     hehe } {    status code: 200, headers {
"Content-Encoding" = gzip;
"Content-Type" = "text/html; charset=UTF-8";
Date = "Fri, 11 Jan 2019 23:51:59 GMT";
Server = Apache;
"x-powered-by" = "PHP/7.1.25";
 } })
el conductor acepto el viaje.. enviando cotizacion
DispatchQueue.main.async {
                if blog.Response == "true" {
                    print(data)
                    print(response)
                    print("el conductor acepto el viaje.. enviando cotizacion")
                    for article in blog.articles {

                        let precio = article.Precio
                        self.elconductorcobra.text = "Costo del viaje \(precio)" // hereeeeeee

                        break
                    }

                }

                if blog.Response == "false" {

                    print("esperando a que el conductor envie la cotizacion...")

                }
                else {
                    print(error)
                    print("error hapend :0")

                }

            }