• 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 37 views
0 votes
1 answer 1 view
1 view
Problem: I am in need of assistance, and any suggestions will be greatly appreciated,"uncaught error call to undefined function mysql_connect() php 7."
asked 2 hours ago sumaiya simi 7.7k points
0 votes
1 answer 27 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 193 views
0 votes
1 answer 711 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
1 vote
1 answer 4 views
Problem: Why I got the error : php fatal error: call to undefined function mysql_connect()
asked Apr 2 MUHAMMAD MUNEEB 80k points
0 votes
1 answer 7 views
Problem: Hi any one who can fix this? call to undefined function mysql_connect php
asked Mar 19 PkGuy 13.1k points
0 votes
1 answer 4 views
Problem: As I mentioned in my previous query, I'm having difficulties with my learning; I've tried searching the web but haven't been able to find adequate information; could you assist me in continuing my project?
asked Apr 1 rakib1 50.4k points
1 vote
1 answer 6 views
Problem : First time I install XAMPP , I can use it normally. But when I try to connect to MySQL, I got this error. <?php define("DB_HOST","localhost"); define("DB_USER","root"); define("DB_PWD",""); define("DB_DBNAME","text"); define("DB_CHARSET","utf8"); ... ("Error:".mysql_error().":".mysql_error()); mysql_select_db(DB_DBNAME); return $link; } Any ideas on what I need to do to fix this? Thanks!
asked Mar 27 Shovo210 13.2k points
0 votes
1 answer 4 views
Problem: What are my options for resolving this problem? Mengatasi uncaught error: call to undefined function mysql_connect().
asked Apr 1 rakib1 50.4k points