php does not recognize the mysqli_connect() command

Asked

Viewed 181 times

-1

I am running a coigo via cmd and he started to present this error PHP Fatal error: Uncaught Error: Call to Undefined Function mysqli_connect() in /opt/lampp/htdocs/php/football/Crawler/php/crud/Conect.php:6 Stack trace:

0 /opt/lampp/htdocs/php/football/Crawler/php/crud/Conect.php(13): Conn('root', '', '127.0.0.1', 'football')

1 /opt/lampp/htdocs/php/football/Crawler/autoload.php(3): require_once('/opt/lampp/htdo...')

2 /opt/lampp/htdocs/php/futebol/Crawler/instatscout/Rastrear_metchs_tournament.php(7): autoload('php/crud/Conect...')

3 {main}

thrown in /opt/lampp/htdocs/php/football/Crawler/php/crud/Conect.php on line 6 code

if (!function_exists('conn')) {
    function conn($usuario,$senha,$host,$bd)
    {

        $conn = mysqli_connect($host, $usuario, $senha, $bd);
        if (!$conn) {
            die("Connection failed: " . mysqli_connect_error());
        }
        return $conn;
    }
}
$conn = conn( "root",'',"127.0.0.1","futebol");

1 answer

1


If you installed Lamp by downloading from Xampp then just go to php.ini and uncomment the line:

;extension=mysqli.so

To (removes the ;):

 extension=mysqli.so

If it is php7 probably could be like this:

;extension=mysqli

To (removes the ;):

 extension=mysqli

Save the edit after saving the php.ini I restarted the Lamp:

sudo /opt/lampp/lampp stop
sudo /opt/lampp/lampp start

I don’t remember if there’s a restart for a long time I don’t use xampp, I only use what comes through the repository, but you can try:

sudo /opt/lampp/lampp restart

Just for the record, Xampp if I am not mistaken has a panel that can restart Apache, mysql and others by itself, without needing commands.

  • Yes xampp has the xampp control panel to open the panel, whose file name I don’t remember but is in the same installation folder. Anyway you can also start by command with . /xampp start or even indicating what you want to start with . /xampp startapache

Browser other questions tagged

You are not signed in. Login or sign up in order to post.