mysqli_query():行中的空查询

I'm confused by xcode and php due to the fact that the exact same code, which works within the iOS simulator, doesn't work for the iPhone itself.

The php file looks like the following:

<?php
$con=mysqli_connect("localhost","BLACKEDOUT","BLACKEDOUT","BLACKEDOUT"     );

$array = json_decode($_POST["identifier"]);

for($i=0; $i < count($array); $i++)
{
$name = $array[$i][1];
for($j=0; $j < count($array[$i][0]); $j++)
{
    $nummer = $array[$i][0][$j];

    $query = "SELECT x FROM Z WHERE uniqueID = $nummer";
    $dbConn = new PDO('mysql:host=localhost;dbname=BLACKEDOUT', "BLACKOUT", "BLACKEDOUT");
    $smt = $dbConn->prepare($query);
    $smt->bindParam(1, $phone_num );
    $smt->execute();
    if($smt->rowCount())
        {
             $ergebnisArray[] = [$name,$nummer];
    }
    else 
    {
    }
     }

}
echo json_encode($ergebnisArray);

mysqli_query($con, $query) or die ("Could not connect to server");

mysqli_close($con);

?>      

When running the code in the iOS simulator it's all fine, but when I run it on my device it says: as the response string in Xcode: "mysqli_query(): Empty query in on line 30". When I work around that error, I don't get the result I expect either.

Every help is greatly appreciated!

Note, that you use BLACKOUT and BLACKEDOUT mixed, and you never use $con. Also, be aware that you define $query inside a loop, so when it iterates zero times, $query never gets defined, thus cannot by used in mysqli_query.

Try this and come back with the result:

<?php
$array = json_decode($_POST["identifier"]);

for($i=0; $i < count($array); $i++)
{
$name = $array[$i][1];
    for($j=0; $j < count($array[$i][0]); $j++)
    {
        $nummer = $array[$i][0][$j];

        $query = "SELECT x FROM Z WHERE uniqueID = '".$nummer."'";
        $dbConn = new PDO('mysql:host=localhost;dbname=BLACKEDOUT', "BLACKOUT", "BLACKEDOUT");
        $smt = $dbConn->prepare($query);
        $smt->bindParam(1, $phone_num );
        $smt->execute();
        if($smt->rowCount())
            {
                 $ergebnisArray[] = [$name,$nummer];
        }
        else 
        {
        }
    }

}
echo json_encode($ergebnisArray);
?>