A man was flogged inside a Malaysia mosque on Friday after being convicted of an Islamic offence for spending time alone with a woman who was neither his wife nor relative, state news said.