Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (6.1k points)

I have set up the 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?

1 Answer

0 votes
by (12.7k points)
edited by

You have upgraded to PHP 7, and now the mysql_connect is deprecated. Check it now yours with :

php -version

Change it to mysqli_connect as in: 

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

If you're upgrading legacy PHP, now you're faced with the task of upgrading all your mysql_* functions with mysqli_* functions. 

I hope this helps !

If you want to learn more about SQL, Check out this SQL Certification by Intellipaat.

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories

...