PHP变量不是mysqli对象

I have the next code (compilated in NetBeans)

$query = 'INSERT INTO grupos(nombre, descripcion)'
            . ' VALUES ("' . utf8_decode($_POST['name']) . '", "' . utf8_decode($_POST['desc']) . '")';
    $result = $con->query($query) or exit("Error: " . $con->errno . ": " . $con->error);
    if ($result->affected_rows > 0) {

Why I got this: "Trying to get property of non-object " if when I made a echo $result; display a '1'?

From the documentation of mysqli::query():

For successful SELECT, SHOW, DESCRIBE or EXPLAIN queries mysqli_query() will return a mysqli_result object. For other successful queries mysqli_query() will return TRUE.

Since your query is INSERT, not SELECT, it doesn't return a mysqli_result, it just returns TRUE. You should use $con->affected_rows instead of $result->affected_rows.