If we start with free-body diagrams for each of the two masses(which I unfortunately cannot reproduce here) we find that the forces acting on m1 (the 9 kg weight) are tension T in the positive y direction and weight (m1g) in the negative y direction. Newton's second law F=ma for this block then reads:
T-m1g=m1a1 <---equation 1
where a1 is the acceleration of m1
The forces acting on m2 (the 5 kg block) are tension T in the negative x direction, friction f in the positive x direction, a normal force N in the positive y direction, and weight in the negative y direction. I chose to orient my diagram so that the movement of each mass will be in a negative direction, assuming we agree to use the traditional x and y coordinate system. Using the forces in the y directions and F=ma yields N-m2g=0 (since the block is not accelerating vertically) or N=m2g. This will be useful for the frictional force. The forces in the x direction combine with Newton's second to give:
-T+f=m2a2 <---equation 2
using the definition of the frictional force f=uN and the fact that a1=a2 (since we assume the rope does not stretch or break) we can rewrite equation 2:
-T+uN=m2a1 <---equation 3
Using equations 1 and 3 we have 2 equations with two unknowns(T and a1). For me the simplest way to solve for the tension is to divide one equation by the other and thereby eliminate a1 altogether. What is left is one equation with one unknown variable. Let me illustrate:
T-m1g = m1a1 <---equation 1
----------- -------
-T+um2g = m2a1 <---equation 3
It looks a bit awkward here but the point is that we now have one equation consisting of fractions on either side. On the right side the a1's cancel leaving us with the tension as our only unknown. If you then cross multiply, group all the terms with T on side and all the other terms on the other side, factor out and solve for T you get:
T=(um2gm1 + m1m2g)/(m1 + m2)
(apologies for skipping the algebra)
using the numbers you gave in the question I get a result of 38.8[Newtons]