• Register
0 votes

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?

7 5 2
3,870 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


Please use "mysqli_connect" as shown below :

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

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


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.

9 7 4
38,600 points

Related questions

0 votes
1 answer 11 views
0 votes
1 answer 10 views
What i am attempting to make a easy connection with XAMPP and MySQL server, however whenever I attempt to enter data or connect to the database, i obtain this error. Why this is happen and how to solve it?
asked Sep 14, 2020 Daniel Anderson 4k points
0 votes
1 answer 38 views
0 votes
1 answer 260 views
Problem : I am facing below error : Fatal error: Uncaught Error: Call to undefined function mysql_escape_string() in D:\xampp\htdocs\phoenixproject\register.php:16 Stack trace: #0 {main} thrown in D:\xampp\htdocs\phoenixproject\register.php on line 16 Well I know one thing that I am trying to mix the mysql and mysqli. Still how can I fix above issue ?
asked Dec 21, 2019 alecxe 7.5k points
0 votes
1 answer 90 views
can someone help me why i am seeing “PHP Fatal error: Uncaught Error: Call to undefined function mysql_query() in /Applications/MAMP/htdocs/lprapp/config.php:23 Stack trace:#0 {main} thrown in /Applications/MAMP/htdocs/lprapp/config.php on line 23&rdquo” this error and how to resolve it.
asked Sep 14, 2020 Daniel Anderson 4k points
0 votes
1 answer 17 views
0 votes
2 answers 36 views
Need Help: How to make an ajax call to populate my dropdown list when the page is loading in Php? And, how to make the ajax call to refresh my table when I make a selection on my dropdown list?
asked Nov 9, 2020 Reina Joy 360 points
1 vote
1 answer 40 views
Problem : I am very new to XAMPP, MYSQL and phpMyAdmin. I have the MYSQL table which contains nearly the 7 million records. When I try to access the big table from my phpMyAdmin I always face below error: Fatal error: Maximum execution time of 30 seconds ... a maximum execution time to the maximum possible value. I am very confused about this error so looking for help on this XAMPP error.
asked May 18, 2020 Martin K 6.6k points
0 votes
1 answer 22 views
Problem: I am facing the error " the fatal error, Call to undefined function get_header(), in C:\xampp\htdocs\hatch\index.php on line number one ".
asked Dec 12, 2020 prog_learner 2.5k points
0 votes
1 answer 64 views
Problem: Just to brief the title, I want to make a bar chart that will read data from a database table using MySql, and auto adjust the height to fit the new data. The data enters the database through the Arduino microcontroller, so data is repeatedly added ... data and increase its height according to it. Is there a way to do this without constantly refreshing the webpage every 0.5 seconds?
asked Dec 7, 2020 sasha 5.3k points