• Register
0 votes
183 views

Problem :

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

“Fatal error: Call to undefined function mysql_connect()”

How can I fix this Fatal Error?

3.9k points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

You need to open your terminal and run the bbellow command.

sudo apt-get install mysql-server

After that if you are running the PHP then you will also need to install a php module for your mysql 5 with below command:

sudo apt-get install php5-mysql

 OR

Please use "mysqli_connect" as shown below :

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

it will certainly work, I have fixed my problem with this .

OR

If you are using the Windows10, PHP 7.2 and try to connect to mysql. If above error occurred

Then please do the following steps to get it corrected.

1.    Go to your PHP installation folder,

2.    Check for your php.ini file, (Only dev, prod file is there, then one of your file as php.ini file)

3.    Look for the "extension=mysqli" and remove a ";" before it.

4.    Look for the "extension_dir" and mentioned your path of "ext" directory.

5.    Finally restart the application.

Hope this will help you in resolving your issue.

38.6k points

Related questions

0 votes
1 answer 24 views
24 views
Problem: Please, want an answer : Fatal error uncaught error call to undefined function mysql_connect()
asked Jun 18 asha 121k points
0 votes
1 answer 12 views
12 views
Problem: I have no idea to solve this, somebody help : Fatal error uncaught error call to undefined function mysql_connect() in xampp
asked Jun 15 nila 121k points
0 votes
1 answer 11 views
11 views
Problem: What is wrong here : Cara mengatasi fatal error: uncaught error: call to undefined function mysql_connect() in?
asked Jun 12 Priscilla Gurpreet 74.7k points
0 votes
1 answer 75 views
0 votes
1 answer 7 views
7 views
Problem: What exactly is the solution : Uncaught error call to undefined function mysql_connect() php 7?
asked Jun 21 Nahil 128k points
0 votes
1 answer 5 views
5 views
Problem : Is there a method to resolve this issue: Uncaught error call to undefined function mysql_connect() in php?
asked Jun 20 Siam55 110k points
0 votes
1 answer 15 views
15 views
Problem: Is there anyone who can help me to solve this problem,'Fatal error: Uncaught Error: Call to undefined function mysql_connect()'.?
asked Apr 12 Moumita Bhowmick 12.9k points
0 votes
1 answer 13 views
13 views
Problem: Any suggestions will be greatly appreciated,"Uncaught error call to undefined function mysql_connect() php 7."
asked Apr 11 sumaiya simi 43.9k points
0 votes
1 answer 12 views
12 views
Problem: I am trying to do a simple connection with XAMPP and MySQL server, but whenever I try to enter data or connect to the database, Fatal error: Uncaught Error: Call to undefined function mysql_connect().
asked Apr 11 Moumita Bhowmick 12.9k points
0 votes
1 answer 35 views
35 views
Problem: What is wrong here : Uncaught error call to undefined function mysql_connect()?
asked Jun 24 nila 121k points