Shanghai -- Hong Kong train runs every other day, the journey takes 25h46min. Train number is K99, leaving Shanghai at 1124 and arriving Hong Kong (Hung Hom station) at 1310 the next day.
I'd highly recommend the comfy overnight Z trains for Beijing -- Shanghai. These are definitely better than flying. Reason being that you get a night's accommodation thrown in for the price (478/499 RMB for soft sleeper upper/lower bunk) and you also save of the time and cost of travelling from Beijing city to Beijing airport, and again from Shanghai airport to Shanghai city. The trains are overnight and take only 12 hours. The flights take 2 hours journey time, plus arriving 1 hour early to check-in, and at least 1 hour travelling time each way; assuming no flight delays, that's at least 5 hours of precious daylight time wasted, which could've been better used sightseeing!
Take a look at http://www.wunderground.com for historical weather conditions. Shanghai's temperature is usually around freezing point, and quite damp; Beijing will be colder but drier.
If your friend was working in China, where? It's possible to rent an apartment which would cost 9 EUR/day, but you're not staying that long, so that's out of the question for you! If you're working on that budget, 9 EUR will only get you a dorm bed, not a room -- unless you get a very crappy room that you probably won't want to stay in. I think a budget of at least 160-190 RMB would be reasonable for a pretty basic room in Beijing and Shanghai, while 200 RMB would get you a decent 2-star. Also take note that these cities are huge, it's not worth scrimping to stay in a cheap dive in some obscure location then spend lots of time travelling around to the sights. Hong Kong would be a lot more expensive.
Beijing hostels: Peking Downtown Backpackers Accommodation, Far East IYH and City Central IYH.
In Shanghai, head for Hiker IYH at 450 Jiangxi Zhonglu, 5 mins walk from the Nanjing Donglu metro stop (line 2, exit no.2), telephone number 86-21-63297889. This is the best IYH I've found so far in Shanghai. Stay away from a place called Captain's Hostel, I've gotten such indifferent/impolite/downright rude service from them on so many occasions that I'd not want to recommend them to any other travellers. Buyer beware!