connect to sugarcrm and get some data in my custom php file

I made in new custom php file lets say e.g sample.php placed in root folder accessing it through a ajax call in any module but i am not able to connect to database or perform any operation. How to do that anyone can help?