Boolean
The Boolean modifier needs a closed mesh to work properly, see the wiki:
This means that this modifier will only work properly for the intersection of faces of the two meshes that will result in another closed loop of edges (filled with faces), creating a new resulting face topology.
(You can have an open mesh as long as the open parts do not intersect or interact with the boolean operation)
Removing the middle section of the cube should fix it:
You may also need to recalculate the normals (CtrlN)
Also ensure that:
The Modifier is applied to the cylinder.
The Operation is set to Difference:
Knife
In addition to the Knife project tool mentioned by Haunt_House, You may want to use the Knife tool for this:
In edit mode, press K to start the knife tool and C to enable Angle Constrain. (you may need to hold shift at some points to place a cut, due to the view not being aligned perfectly to the topology)
Modeling
Another simple way to do this is to use Loopcuts:
Press CtrlR and use the scrollwheel or the keyboard to set the number of cuts:
You can then use Edge slide (GG or CtrlE> Edge slide) to slide them into the correct position:
An advantage to this is that this does not produce N-gons (see this)