smt-> close()之后没有任何反应;

时间:2018-05-21 19:53:24

标签: php

我试图在我的代码的某些部分使用echo进行调试,我发现在使用$sql->close();命令后,没有任何反应,甚至没有出现回声。我之前使用了一个echo,显示了文本,并在此命令之后。

你可以在$ stremail之后忽略代码,因为之后我使用了/ *评论......

如果您需要更多详细信息,请告诉我,这是我的第二篇文章,对不起,如果我错过了某些内容。

我希望你能帮助我解决这个问题......

<html>
    <head>
</head>
<body>

<?php require 'connection.php';
//Insere no BD
$id=$_POST['id_quote'];
$idcomp=$_POST['id_quote'];

if(isset($_POST["price"]) && is_array($_POST["price"])){
    $i=0;
    foreach($_POST["price"] as $key => $text_field){
        if($_POST['update']!=true)
        {
        $sql .= "INSERT INTO price (id_quote, id_provider, price)
        VALUES ('". $id ."', '". $_POST["id_provider"]."', '". $_POST["price"][$i]."');";
       $i++;
       $id++;
        }else
        {
            $sql .= "UPDATE price SET price = '".$_POST['price'][$i]."' WHERE id_quote = '".$id."' AND id_provider = '".$_POST['id_provider']."';";
            $i++;
            $id++;
        }
    }  
}

if ($conn->multi_query($sql) === TRUE) {
    echo "Cotações inseridas com sucesso!";
} else {
    echo "Error: " . $sql . "<br>" . $conn->error;
}
echo "antes qtde prov";
$sql->store_result();

//Inicia array de criação de email antes de while
$stremail = Array();
$stremail = array_filter($stremail);

//Qtde de provedores
$sqlprovider = "SELECT * FROM providers";
if ($conn->query($sqlprovider) === TRUE) {
    $numprovider = $sqlprovider->num_rows;
    $sqlprovider->close();
    echo "depois qtde prov";
} else {
    echo "Error: " . $sqlprovider . "<br>" . $conn->error;
}
for($z=$idcomp;$z<$idcomp+$_POST['legs'];$z++)
{
//Confere se todos provedores inseriram preços por cotação
$sqlprice = "SELECT * FROM `price` where id_quote=".$z;

if ($conn->query($sqlprice) === TRUE) {
    if($numprovider==$sqlprice->num_rows)
    {echo "cotacao completa".$z;
        $sqlprice->close();
        //Busca provedor com melhor preço
        $sqlcompara = "SELECT id_provider, MIN(price) as price FROM price WHERE id_quote='".$z."'";
        if ($conn->query($sqlcompara) === TRUE) {
            $row = $sqlcompara->fetch_assoc();
            $idprov = row['id_provider'];
            $sqlcompara-->close();
            //Dados do provedor com melhor preço
            $sqlprovider.= " WHERE id_provider='".$idprov."'";
            if ($conn->query($sqlprovider) === TRUE) {
                $row = $sqlprovider->fetch_assoc();
                $company = row['company'];
                $representative = row['representative'];
                $email = row['email'];
                $sqlprovider->close();

            } else {
                echo "Error: " . $sqlprovider . "<br>" . $conn->error;
            }


        } else {
            echo "Error: " . $sqlcompara . "<br>" . $conn->error;
        }

        //Busca Informações da cotação
        $sqlquote = "SELECT * FROM quote WHERE id_quote='".$z."'";
        if ($conn->query($sqlquote) === TRUE) {
            $row = $sqlcompara->fetch_assoc();
            $acft = row['acft'];
            $dt_flight = row['dt_flight'];
            $origin = row['origin'];
            $destination = row['destination'];
            $fbo = row['fbo'];



        $sqlquote->close();
        } else {
            echo "Error: " . $sqlcompara . "<br>" . $conn->error;
        }

        //Envia email de release
        if(empty($stremail[$idprov]))
       {
        $stremail[$idprov] = "TO: ".$company." <br><br> Dear ".$representative.", <br><br>";
        $stremail[$idprov] .= "I would like to request fuel release for the following itinerary: <br><br>";
        $stremail .='<table id="tabela">
       <thead>
           <tr align=center>
               <td width=100px>Tail#</td>
               <td width=100px>Date</td>
               <td width=50px>Origin</td>
               <td width=50px>Destination</td>
               <td width=200px>Handler</td></tr>
               </thead>'; echo "Inicio".$idprov;
       }
       $stremail[$idprov] .= '<tr align=center>
                <td>'.$acft.'</td>
                <td>'.$dt_flight.'</td>
                <td>'.$origin.'</td>
                <td>'.$destination.'</td>
                <td>'.$fbo.'</td>'; echo " add: ".$idprov;

    }echo "cotacao incompleta".$z;

} else {
    echo "Error: " . $sqlprice . "<br>" . $conn->error;
}
}

print_r($stremail);

$conn->close();


?>


</body>
</html>

2 个答案:

答案 0 :(得分:0)

尝试使用此格式

results = {make_NT() for _ in range(3)}
# or
results = {NT() for _ in range(3)}

答案 1 :(得分:0)

让我们分解一下:

$sqlprovider = "SELECT * FROM providers";
if ($conn->query($sqlprovider) === TRUE) {
  $numprovider = $sqlprovider->num_rows;
  $sqlprovider->close();
  echo "depois qtde prov";

您将$sqlprovider设置为字符串,然后使用该字符串查询数据库。现在,如果查询成功(我认为是这样),你会在某种程度上预期$sqlprovider对象

不是,它错误并退出代码,因此之后没有任何内容被执行。

也许您正在寻找:

if ($result = $conn->query($sqlprovider) === TRUE) {
  $numprovider = $result->num_rows;