There are three things wrong with this project that I can see. First, it's possible for your cathode, or "gnd" - pins to draw too much current. That's already been described, and I won't belabor it. You can rectify that by driving the cathodes with transistors, or by increasing the size of the resistors enough to limit the current with all the LEDs on to something less than 40mA. You can test the circuit in dim light. You'll be tempted to say, "I can turn on only four LEDs at a time, and that'll keep the current at 40 mA." Resist that temptation. Pretty soon, you'll make a coding error that turns them all on, and something will fail.
The first loop in setup() has an omission that could easily damage your Arduino in this circuit. Here's the code:
for(x=0; x<5;x++){
pinMode(gnd[x], OUTPUT);
}
Each of the "gnd" pins is set to OUTPUT, but the output levels aren't established. At reset, the output levels are set to LOW. That means that the first time through the output loop in loop(), all five rows of LEDs will be enabled. With the values you have in the matrix, that would be four LEDs for each ground pin - just barely inside the limit - and 200 mA for the Arduino, again just barely within the limit. If you coded something incorrectly, you could easily exceeed the pins' limits, or the IC's limit of 200 mA. To fix this, I'd recommend setting the output level of each pin to HIGH before you set its mode to OUTPUT. This quirk only affects the first iteration of the loop, because the loop sets the active "gnd" pin to HIGH after each iteration.
The second loop in setup has an error, too, and that error is both your good luck, and the source of your unhappiness. Here's the code:
for(y=0; y<7;y++){
pinMode(led[x], OUTPUT);
}
The loops iterates the variable y, but indexes with the variable x. x has the value that it got at the exit of the previous loop, namely, 5. So, this loop sets pin 12 to OUTPUT, and it does it seven times, while leaving the rest of the "led," or anode, pins as inputs. Instead of driving the pins HIGH, setting them to 1 will just turn on the internal pullup resistors. The LEDs will illuminate, but so dimly that you might not be able to see them. I can't tell from the photograph. To test whether this is the likely reason for your unexpected results, verify that the two LEDs that are illuminated are connected to pin 12.
This set of circumstances bodes well for your Arduino. With only one anode pin active, it seems unlikely that there was ever enough current to damage your cathode pins. I recommend - as does everyone else - that you redesign your circuitry to allow for turning on all the LEDs without damaging your Arduino. Replacing the 330 ohm resistors with 680 ohm resistors should keep the current in each ground pin below 35 mA; if you want full brightness, you'll need to get some transistors, or some other way of driving the LEDs.