'i''ve been having a stomach ache and green stool since last night. What is the problem? '

Viral illness. Most likely is a viral illness (gastroenteritis) which can cause increased intestinal activity (the pain) and more frequent stools. And the rate at which stool passes through the intestines can cause a change in color - the green stool you noted.