Sounds like you simply don't have the [man]mysql[/man] extension enabled. However, note that the mysql extension has been replaced with [man]MySQLi[/man] ("MySQL Improved"), so you would be advised to use that (or something like [man]PDO[/man]) instead. Otherwise, you'll need to enable the 'mysql' extension in your php.ini file.
roshanajaml wrote: I cant connect to mysql using phpmyadmin as well
Well then that's a configuration issue on your part, because phpMyAdmin is perfectly capable of using the MySQLi extension as well.