The cost basis of any investment is the cost of the original purchase plus any commissions, fees, or subscriptions that accompanied the investment.
The cost basis of an investment is the total cost of that investment, including the amount spent to purchase it, any commissions or fees associated with that purchase, and any other related costs (for stocks, rarely anything). For tax purposes, the cost basis of an investment can be reduced by certain items, but only rarely. Most common (for businesses) are depreciation and depletion (e.g., oil, timber, minerals depletion allowances).
Accounting for cost basis reveals the true returns of investments, as high commissions or fees, either from high fee structures or frequent trading, reduce the net returns of the investment.
Do note, however, that dividends do not lower the cost basis of an investment, either when received in cash or when used to purchase new shares. A stock dividend, however, does adjust cost basis, as does a "return of capital."
Example of basis
Suppose you buy 37 shares of a company at $45. Your broker charges you $7.99 in commissions to handle that transaction for you (hey, they gotta eat too). What is your total cost, or basis?
Easy. 37 x $45 + $7.99 = $1,672.99. This works out to be $45.216 per share.
Cash dividends, as noted, do not reduce your basis, despite what the historical price section on Yahoo! Finance indicates (that's just to make it easier to calculate what total returns would be including reinvested dividends). However, splits and stock dividends do. For an example of the latter, see the dividends page.
For a split (like 3:2 or 2:1 or 3:1), you increase the number of shares by the split factor, which necessarily reduces the per share cost basis. Suppose that stock you purchased above splits 3:1. Your new basis would be $1,672.99 / 111 shares = $15.072 per share, now. (But your total basis, $1,672.99, remains the same.)
Compare: Cost of goods sold