Clarification on uses of posedge in "if"

Solution 1:

You get the syntax error because the usage of the posedge keyword is illegal in the following line:

    if (posedge counter[26]) begin 

It is illegal because there is no timing event control. For example, @(posedge something) uses the posedge keyword along with an edge control construct: @( ).

Instead of using posedge there, you should create separate logic for an edge detector of the count[26] signal; let's call it pe_count26.

Furthermore, I recommend separating your 2 counters into 2 separate always blocks.

always @(posedge clk) begin
    if (!enable) begin 
        counter <= counter + 1;    
    end
end

always @(posedge clk) begin
    if (pe_count26) begin 
        seven_output <= seven_output + 1;
    end
end

It is a recommended good coding practice to use nonblocking assignments (<=) for sequential logic. I changed your seven_output assignment accordingly.