If it's a 2G, 3G or 3GS then I can help.
I take it you used the headphones recently?
There is a switch inside the headphone jack that can become stuck, it will make the speaker and microphone on the iPhone stop working as it still thinks the headphones are plugged in, it used to happen now and then on the older models.
To fix it you have to keep plugging and unplugging the headphones into the jack, after a while the speakers will start working again. It may take a while but it will fix your problem.
Start playing a song on the phone and then start plugging and unplugging, the iPhone will pause the music each time so you will have to press play to see I it has worked.
It happened to me the odd time on my 3G, took 10 minute to fix once.