Fatal error: Call to undefined function mysql_connect()


I have set up PHP, MySQL, and Apache. localhost() for PHP and it is working well. But after I downloaded MySQL, it reports:

Fatal error: Call to undefined function mysql_connect()


How can I fix this?




In the latest version of PHP 7, the mysql_connect is deprecated. You can check out the version using the below statement.

hp -version


You will need to change to mysqli_connect as:

$host = "";

$username = "root";

$pass = "foobar";

$con = mysqli_connect($host, $username, $pass, "your_database");


If you want to unleash your potential in this competitive field, please visit the SQL course page for more information, where you can find the SQL tutorials and SQL frequently asked interview questions and answers as well.


This topic has been locked/unapproved. No replies allowed

Login to participate in this discussion.

Leave a reply

Before proceeding, please check your email for a verification link. If you did not receive the email, click here to request another.