Mi problema es al verificar si hay un registro en la base de datos

    $category_id = $_POST["category_id"]; 
		$name = $_POST["name"];
		$lastname = $_POST["lastname"];
		$address = $_POST["address"];
		$email = $_POST["email"];
		$phone = $_POST["phone"];
		$created_at = date('Y-m-d');

		$veri = "SELECT count(*) FROM medic WHERE name = '$name' ";
		$result = $db->select($veri); 
		$row = $result->fetch_row();
		$user_count = $row[0];
		if($user_count>0) {echo "1";}
		else {
		    $query = "INSERT INTO medic (name, lastname, email, address, phone, created_at, category_id) VALUES  ('$name',
		    			 '$lastname',
		    			 '$email',
		    			 '$address',
		    			 '$phone',
		    			 '$created_at',
		    			 '$category_id')";
			$r = $db->select($query);
			echo "Datos Insertado";
		}

Me da el fallo:

>"Trying to get property of non-object in" 
No tengo ni idea de lo que puede estar fallando