Programmatically (PHP) get the nr. of items in the primary navigation menu

You are not providing the correct parameter to wp_get_nav_menu_object() function. It needs the menu ID or menu slug but you are providing the menu theme location. Obviously, I can not tell you what is the ID or slug of your menu.

One way of getting the menu ID of the menu assigned to theme location is using get_nav_menu_locations():

$menu = wp_get_nav_menu_object( get_nav_menu_locations()['primary'] );
echo $menu->count;

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)