Is there any way to repair a broken ship in kerbal space program
Repairing Spacecraft
No there isn't sorry.
At the current state of Kerbal Space Program, whatever you do to your ship is final.
A good way to "repair" the ship, is to put docking ports on every part of the ship, and dock it together during assembly. This way, if for example, the left rocket breaks, you can send a new one up, detach the old one, and put the new one on.
Currently this would be classified as the "only way". (As of Beta 1.0)
"Re-inflating" Spacecraft
So Spacecraft cannot be "repaired". But they sure as hell can be re-inflated!
By this I mean that if a tyre pops, for example on a rover, then you can get a Kerbal to EVA up to the tyre, Right Click the tyre, and "repair" it, which re-inflates it, fixing it. (As of Beta 1.0 you need an Engineer with the correct rank to do this.)
The same can be done with landing gears, and re-packing parachutes.
Currently these are the only things repairable. (As of Beta .90)
Engineer Ranks:
Level 0 engineers have no special abilities.
At level 1, they can repack parachutes.
At level 2, they can repair wheels.
At level 3, they can repair lander legs.
They gain no further abilities with additional levels.
More information on Experience can be found here.
Repairing the KSC
Sure, buildings can collapse and be destroyed if enabled upon save creation, but repairing them is even easier. Just Right Click the building of your choice, and a "Repair" option will appear. Warning: This feature will cost money if you're not in Sandbox
Using the Kerbal Attachment System mod (KAS) you can attach and move some parts on ships, in addition to other functions. You can launch a new solar panel up, then EVA and attach it to the ship that the panel broke on.
Launch a rocket with a solar panel on it to rendezvous with the damaged craft.
When you have rendezvoused with the damaged craft, EVA a Kerbal.
Right click on the solar panel when next to it, and select "Grab".
Move to the damaged craft, where you want to place it.
Right click on the solar panel on your back, and select "Place".