Error: Uncaught Error: Class 'mysqli' not found

0

I'm using Apache to make a localhost site, but I have an online bank and wanted to access it

I make the connection in php

<?php           
    $servername = "host.com";
    $username = "user";
    $password = "pass";
    $dbname = "banco";

    $conn = new mysqli($servername, $username, $password, $dbname);

    if ($conn->connect_error) {
        die("connection failed: " . $conn->connect_error);
    }
?>

But when I go to the site it returns me to the following message

  

Fatal error: Uncaught Error: Class 'mysqli' not found in C: \ Apache24 \ htdocs \ folder \ index.php: 133 Stack trace: # 0 {main} thrown in C: \ Apache24 \ htdocs \ folder \ index .php on line 133

I tried to edit "php.ini-development" and php.ini-production in the PHP folder by putting extension_dir = "C:/PHP/ext" but did not work

    
asked by anonymous 21.08.2017 / 17:13

1 answer

1

The php.ini of Apache is generally different from the php.ini they see in php, if you installed php and apache manually you should set the PHPIniDir parameter in httpd.conf, assuming your php is in C: .

If it's PHP5:

LoadModule php7_module "C:/php/php5apache2_4.dll"
PHPIniDir "C:/php/php.ini"

If it's PHP7:

LoadModule php7_module "C:/php/php7apache2_4.dll"
PHPIniDir "C:/php/php.ini"
  

I think that usually the dlls php5apache2_4.dll and php7apache2_4.dll are in the TS version of PHP, I believe that the NTS does not contain, but I'm not sure (I'll review this information).

     

Read more about TS and NTS in Thread Safe (TS) and Non Thread Safe (NTS) - What are they? the difference?

Being Apache for Windows with Apache2handler it is necessary to download PHP Thread Safe in the link: link , if already with php correct ignore this step.

If you know the path that is in PHPIniDir "...." then look for it and edit the extensions by taking ; from the front of the line should look similar to this:

extension=php_mbstring.dll
extension=php_exif.dll; Must be after mbstring as it depends on it
;extension=php_memcache.dll
;extension=php_mysql.dll
extension=php_mysqli.dll

Then after that it is necessary to restart Apache, if installed manually will depend on the type of installation.

If you do not have control panel but have installed as service you can try the command:

cd C:\Apache24\bin
httpd -k restart

If it does not work because it is not a service, then you may have installed the Apache Service Monitor, you can restart it:

Ifnothingsucceeds,thentrytologoffwindows,orrestartwindows.

ForthoseusingXamppyoucanusethepanelitself,clickStopnexttoApacheandthenclickStart:

    
21.08.2017 / 20:21