if you've installed php and mysql in your linux machine, php needs php-mysql extention to communicate with mysql. so make sure you've also installed this extention using:
sudo yum install php-mysql in redhat based machines.
and
sudo apt-get install php-mysql in debian machines.