I am trying to run a python script from php and access a mysql database it works completely when i use
$python sample.py
but on using
$output=shell_exec('python sample.py');
echo $output
it doesn't execute the python script though .php has the permissions
$sudo chmod +x sample.php
$sudo chown www-data:www-data sample.php
$sudo chmod u+x sample.php