Don't use h as the variable of integration since it's already being used as the height of the pyramid. Pick a different letter.
This problem is like the example except that we don't have numbers anymore. We just have letters. Good grief. Since h is being used as the height of the pyramid, let's use y for the distance from the top of the pyramid to a slice. We will use y as the distance from the top of the pyramid to the slice, rather than the bottom of the pyramid to the slice. It makes the similar triangle ratios nicer. We cut the pyramid down the middle to see the similar triangles. Letting x be the length of the side of the square, we have
The area of the square is
and the volume of the slice is
The volume of the pyramid is
Let's evaluate the integral. Remember that b and h are constants, so we can move them outside of the integral: