Syntax for $wpdb->prepare when searching in two columns

The part after WHERE decides which columns are searched.

So you need to change it this way:

$foods = $wpdb->get_results(
    $wpdb->prepare(
        "SELECT id, foodname, namevariations, calories, carbs, fat, protein, sodium FROM foodsTable WHERE namevariations like %1$s OR foodname like %1$s",
        '%' . $wpdb->esc_like( $search_text ) . '%'
    ),
    ARRAY_A
);

Also you were using LIKE queries incorrectly. If the $search_text contained % character, it would be interpreted as wildcard and not as simple character. That’s why I’ve added some escaping in your code. More on this topic here: How do you properly prepare a %LIKE% SQL statement?

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