Fatal error: Call to undefined function mysqli_connect ()

1

I'm doing some web pages to refresh knowledge and hobbie, however, when I copied all the files from my pc (windows 7) where I did tests to a server linux centos shows me the following error:

Fatal error: Call to undefined function mysqli_connect () in /var/www/html/Outsourcing/conecta_mysql.php on line 11

It does not hurt to indicate that in my test environment (my PC) it works, and that's why I uploaded it to Linux.

My php.ini has the following info:

Build Date: Mar 7 2018 13:35:39 Server API: Apache 2.0 Handler Virtual Directory Support: disabled Configuration File (php.ini): Path / etc Loaded Configuration File: /etc/php.ini

Version:

[root @ localhost ~] # php -v PHP 5.4.16 (cli) (built: Mar 7 2018 13:34:47) Copyright (c) 1997-2013 The PHP Group Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

I hope you can help me.

Thank you.

    
asked by Adrian 09.03.2018 в 23:18
source

1 answer

1

Hello friend, I hope you are very well, this happened to me because in my file "php.ini" I had a commented extension line, I will help you, the first thing you will do is enter the next route through the terminal :

cd /etc/php/7.0/apache2

We are already in the apache folder called "apache2" now, we must give permission to the file called "php.ini" that is in the folder mentioned above to be able to modify and save the changes that we will make later, it is enough to place in the terminal:

sudo chown 777 php.ini

And now, you can modify and save, what follows is to do the following, you will open the file "php.ini" as follows:

nano php.ini

The document will be opened and what you will do is press the key combination CTRL + W and a search engine will open (a white bar in the terminal), there you will write:

;extension=mysqli

As you can see before the word "extension" there is a semicolon ; that means that that line inside our file "php.ini" is commented, we must decompose it, that is, we must remove the ; from there, we would have something like this:

extension=mysqli

We press CTRL + O to save, it will tell us that if we are sure, we say that if and then we go out with CTRL + X, the last thing we will do is restart apache and this is achieved with this command:

sudo /etc/init.d/apache2 restart

And now, little brother, you should be ready: D I hope my answer has helped you.

    
answered by 10.03.2018 в 03:46