I'm a newbie to ubuntu,and im trying to connect the mysqlworkbench(database) with php5.3

if (function_exists('mysql_connect')) {
 echo "Good<br />\n";
} else {
echo "Bad.<br />\n";

I'm getting the output as Bad and then i tried with mysqli_connect ,that is also not exists in my scenario. Is there any way to solve this issue?

Thanks in Advance.. show some examples to tackle this

  • try mysql_connect("localhost","username","password"); – Aatish Sai Jan 8 '14 at 11:40
  • That looks like what would happen if you compiled PHP yourself without MySQL support, which shouldn't be the case if you're using the PHP from Ubuntu. Did you install PHP from the official packages? Can you tell us how you installed PHP? – thomasrutter Jan 8 '14 at 11:42
  • i tired this and there is no response. so i check the existence by function_exists('mysql_connect').. it gives as FALSE.. – Joyal Jan 8 '14 at 11:43

I'm assuming you've installed PHP and MySQL using regular Ubuntu packages. Then install the php5-mysql package to have MySQL bindings for PHP. E.g.

sudo apt-get install php5-mysql

You may need to restart your web server to make the changes effective.

Verify with a simple phpinfo PHP file the PHP-MySQL support (mysqli extension).



  • @gertvdijk...thanks a lot .. issue solved by istalling the package to bind the mysql with php – Joyal Jan 8 '14 at 11:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.