PHP检查mysqli_num_rows无效

I've searched thoroughly and nothing seems to be working; I have this code here which posts into my database but the problem is I am trying to run a conditional which checks if a row exists using the mysqli_num_rows function, but it is not actually working. I have tried many different versions and other functions as well such as mysqli_fetch_row, but nothing seems to work. Here is my code:

if (!empty($_POST)) {
    $db_conx="";

    $name = $_POST['name'];
    $module = $_POST['module'];
    $secret = $_POST['secret'];
    $uid1 = $dmt->user['uid'];
    $queryA = "INSERT INTO table_a (uid1,name,module,secret) VALUES ('$uid1','$name','$module','$secret')";
    $resultA = mysqli_query($db_conx,$queryA);
    $queryB = "SELECT 1 FROM table_a WHERE name='$name' LIMIT 1";
    $resultB = mysqli_query($db_conx,$queryB);
    $resultC = mysqli_query($db_conx,$queryB);
    $query = mysqli_query($db_conx,"SELECT * FROM table_a WHERE name='$name'");
    if (empty($name)||empty($module)||empty($secret)) {
        echo "Oops! Can't leave any field blank <br />";
        exit();
    } elseif(mysqli_num_rows($query) > 0){
        echo "name already exists.";
        exit();
    } elseif ($db_conx->query($queryA) === TRUE) {
        echo "New record created successfully.";
        exit();
    } else {
        echo "Error: " . $queryA . "<br>" . $db_conx->error;
        exit();
    }
}

As you can see the query appears to run but indeed does not do what it's told.

The first line of code inside your IF is destroying the variable you are using to hold the database connection

if (!empty($_POST)) {
    $db_conx="";                // get rid of this line

So basically nothing using the mysqli API will work.

ALSO:

Add these as the first 2 lines of a script you are trying to debug

<?php 
error_reporting(E_ALL); 
ini_set('display_errors', 1);

as you are obviously not readng your php error log