PHP Query返回null!不可能

i post the code and the result, may some one can help..

if (isset($_GET['id']) && is_numeric($_GET['id']) && $_GET['id'] > 0)
                {
                    $id = $_GET['id'];
                    echo $login_session_id.$id;
                    include('config.php');
                    set_time_limit(59);
                    $resultEdit = mysql_query($db,"select * from Rubrica where ID_Utente = '$login_session_id' AND ID_Dispositivo='$id' ")or die(mysql_error());;
                    if (!$resultEdit) {
                        die('Invalid query: ' . mysql_error());
                    }
                    if(mysqli_num_rows($resultEdit)==1)
                    {
                        echo 'fatto';
                        while($row = $resultEdit ->fetch_assoc())
                        {
                        echo 'fatto';
                        $id=$row['ID_Dispositivo'];
                        $Username = $row['Username'];
                        $Email= $row['Email'];
                        $Cellulare= $row['Mobile'];
                        $Casa= $row['Home'];
                        $Lavoro= $row['Work'];
                        renderForm($id, $Username, $Email,$Cellulare,$Casa,$Lavoro,$error);
                        }
                    }
                    else
                    {
                        echo "No results!";
                    }
                }
                else
                {
                    echo 'Error!';
                }

            }

result page:

21 18 <---Correct!

i try directly the query and i found one row what i want, why here don't go? i now about the while but i do some test.

All Code ->

<?php
   include('session.php');
?>

<!DOCTYPE html>
<html>
<head>
<title>ControlPannel</title>
<!-- jQuery-->
<script src="/web/js/jquery.min.js"></script>
<!-- Custom Theme files -->
<!--theme-style-->
<link href="/web/css/style.css" rel="stylesheet" type="text/css" media="all" />   
<!--//theme-style-->
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="Panello di controllo applicazione" />
<script type="application/x-javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } </script>
<!--fonts-->
<link rel="icon" href="/web/images/logoB.png">
<!--//fonts-->
</head>
<body>
    <div class="header">
    <!---->
        <div class="header-left">
            <div class="logo">
                <a href="index.html"><img src="/web/images/logo.png" alt=""></a>
            </div>
            <div class="top-nav">
                <ul >
                    <li><h1>Welcome <?php echo $user_check_email; ?></h1> </li>
                    <li class="active" ><a href="" >RUBRICA</a></li>
                    <li><a href="Promemoria.php" class="black" > PROMEMORIA</a></li>    
                    <li><a href="Sos.php" class="black1"> SOS</a></li>
                    <li><a href="imp.php" class="black2" > IMPOSTAZIONI</a></li>
                    <li><a href="LogOut.php" class="black2" > LOGOUT</a></li>
                </ul>
            </div>
            <p class="footer-class">Template by  <a href="" target="_blank">42Studios</a> </p>
        </div>
        <!---->
        <!---->
        <div class="header-top">
            <div class="logo-in">
                <a href="index.html"><img src="/web/images/logo.png" alt=""></a>
            </div>
            <div class="top-nav-in">
            <span class="menu"><img src="/web/images/menu.png" alt=""> </span>
                <ul >
                    <li class="active" ><a href="" >RUBRICA</a></li>
                    <li><a href="Promemoria.php" class="black" > PROMEMORIA</a></li>    
                    <li><a href="Sos.php" class="black1"> SOS</a></li>
                    <li><a href="imp.php" class="black2" > IMPOSTAZIONI</a></li>
                    <li><a href="LogOut.php" class="black2" > LOGOUT</a></li>
                </ul>
                <script>
                    $("span.menu").click(function(){
                        $(".top-nav-in ul").slideToggle(500, function(){
                        });
                    });
            </script>

            </div>
            <div class="clear"> </div>
        </div>
            <!---->
        <div class="content">
            <div class="Block">
                <?php

                    
                    function renderForm($id, $Username, $Email,$Cellulare,$Casa,$Lavoro,$error)
                    {

                        if ($error != '')
                        {
                            echo '<div style="padding:4px; border:1px solid red; color:red;">'.$error.'</div>';
                        }
                    ?>
                <form action="" method="post">
                    <input type="hidden" name="id" value="<?php echo $id; ?>"/>
                    <div>
                        <p><strong>ID:</strong> <?php echo $id; ?></p>
                        <strong>Username: *</strong> <input type="text" name="Username" value="<?php echo $Username; ?>" /><br/>
                        <strong>Email: *</strong> <input type="text" name="Email" value="<?php echo $Email; ?>" /><br/>
                        <strong>Cellulare: *</strong> <input type="text" name="Mobile" value="<?php echo $Cellulare; ?>" /><br/>
                        <strong>Casa: *</strong> <input type="text" name="Home" value="<?php echo $Casa; ?>" /><br/>
                        <strong>Lavoro: *</strong> <input type="text" name="Work" value="<?php echo $Lavoro; ?>" /><br/>
                        <p>* Required</p>
                            <input type="submit" name="submit" value="Submit">
                    </div>
                </form>
                <?php
            }
            include('config.php');
            if (isset($_POST['submit']))
                {
                    echo '1';
                    if (is_numeric($_POST['id']))
                    {
                        $id = $_POST['id'];
                        $Username = mysql_real_escape_string(htmlspecialchars($_POST['Username']));
                        $Email = mysql_real_escape_string(htmlspecialchars($_POST['Email']));
                        $Cellulare = mysql_real_escape_string(htmlspecialchars($_POST['Mobile']));
                        $Casa= mysql_real_escape_string(htmlspecialchars($_POST['Home']));
                        $Lavoro = mysql_real_escape_string(htmlspecialchars($_POST['Work']));
                        if ($Username == '')
                            {
                                $error = 'ERROR: Please fill in all required fields!';
                                renderForm($id, $Username, $Email,$Cellulare,$Casa,$Lavoro,$error);
                            }
                            else
                            {
                                // save the data to the databaseRubrica where ID_Utente = '$login_session_id'
                                mysql_query($db,"UPDATE Rubrica SET Username='$Username',Mobile='$Cellulare',Home='$Casa',Work='$Lavoro',Email='$Email' WHERE ID_Utente = '$login_session_id' AND ID_Dispositivo='$id'")or die(mysql_error());
                                header("Location: RUBRICA.php");
                            }
                    }
                    else
                    {
                        echo 'Error!';
                    }
                }
                else
                {   
                    include('config.php');
                    if ((isset($_GET['id'])) && (is_numeric($_GET['id'])) && ($_GET['id'] > 0))
                    {
                        $id = $_GET['id'];
                        echo $login_session_id.$id;
                        set_time_limit(59);
                        $resultEdit = mysql_query($db,"select * from Rubrica where ID_Utente = '$login_session_id' AND ID_Dispositivo='$id' ")or die(mysql_error());;
                        if (!$resultEdit) {
                            die('Invalid query: ' . mysql_error());
                        }
                        if(mysqli_num_rows($resultEdit)==1)
                        {
                            echo 'fatto';
                            while($row = $resultEdit ->fetch_assoc())
                            {
                            echo 'fatto';
                            $id=$row['ID_Dispositivo'];
                            $Username = $row['Username'];
                            $Email= $row['Email'];
                            $Cellulare= $row['Mobile'];
                            $Casa= $row['Home'];
                            $Lavoro= $row['Work'];
                            renderForm($id, $Username, $Email,$Cellulare,$Casa,$Lavoro,$error);
                            }
                        }
                        else
                        {
                            echo "No results!";
                        }
                    }
                    else
                    {
                        echo 'Error!';
                    }

                }
?>
                ///query
                <div id="risultato"></div>
            </div>
            
        </div>
        <div class="clear"> </div>
        <p class="footer-class-in">Copyright © 2015 Template by  <a href="" target="_blank">42Studios</a> </p>
    </div>
</body>
</html>
            

Data
enter image description here
enter image description here
the select return null

Some issues that I see directly in your code.

1). All include files should basically be on top of your file. All include and required files should always be at top.

2). Your if statement is not correct. You should use () for your conditions.

3). The function mysql_query accepts parameters in this way :-

mysql_query(query, connection)

So your final code should be something like this :-

<?php
include('config.php');
if ((isset($_GET['id'])) && (is_numeric($_GET['id'])) && ($_GET['id'] > 0))
                {
                    $id = $_GET['id'];
                    echo $login_session_id.$id;
                    set_time_limit(59);
                    $resultEdit = mysql_query("select * from Rubrica where ID_Utente = '$login_session_id' AND ID_Dispositivo='$id' ", $db)or die(mysql_error());;
                    if (!$resultEdit) {
                        die('Invalid query: ' . mysql_error());
                    }
                    if(mysqli_num_rows($resultEdit)==1)
                    {
                        echo 'fatto';
                        while($row = $resultEdit ->fetch_assoc())
                        {
                            echo 'fatto';
                            $id=$row['ID_Dispositivo'];
                            $Username = $row['Username'];
                            $Email= $row['Email'];
                            $Cellulare= $row['Mobile'];
                            $Casa= $row['Home'];
                            $Lavoro= $row['Work'];
                            renderForm($id, $Username, $Email,$Cellulare,$Casa,$Lavoro,$error);
                        }
                    }
                    else
                    {
                        echo "No results!";
                    }
                }
                else
                {
                    echo 'Error!';
                }

            }

            ?>

The problem was i use mysql_query instead mysqli_query.