Error: "Call to Undefined Function mysqli_init"

Asked

Viewed 3,620 times

2

I am running a test with the codeigniter 3.1.5 framework and when trying to connect with the database it presents the following error:

Fatal error: Call to Undefined Function mysqli_init()

The description of the complete error:

Fatal error: Call to Undefined Function mysqli_init()

in C: vm ci system database drivers mysqli mysqli_driver.php on line 135

A PHP Error was encountered Severity: Error

Message: Call to Undefined Function mysqli_init()

Filename: mysqli/mysqli_driver.php

Line Number: 135

Backtrace:

I really want to know where I’m going wrong! My scenario is very simple:

  • Windows 10 Enterprise
  • PHP 5.6.1 installed
  • Using the built-in PHP server php -S localhost:8080
  • Mysql installed in 3309 port version 5.7.18

The databese CI configuration code:

    active_group = 'default';
    $query_builder = TRUE;

    $db['default'] = array(
   'dsn'    => '',
   'hostname' => 'localhost',
   'username' => 'root',
   'password' => 'root',
   'database' => 'blog',
   'dbdriver' => 'mysqli',
   'dbprefix' => '',
   'pconnect' => TRUE,
   'db_debug' => (ENVIRONMENT !== 'production'),
   'cache_on' => FALSE,
   'cachedir' => '',
   'char_set' => 'utf8',
   'dbcollat' => 'utf8_general_ci',
   'swap_pre' => '',
   'encrypt' => FALSE,
   'compress' => FALSE,
   'stricton' => FALSE,
   'failover' => array(),
   'save_queries' => TRUE,
   'port'=>'3309'
     );

I want to know what’s wrong there?

  • Mysqli is active in php.ini ?

  • @Otto Yes this one! It displays the following message in CLI: PHP Startup: Unable to load Dynamic library 'C: php ext php_mysqli.dll' - Could not find the specified module. in <b>Unknown</b> on line <b>0</b><br /> DLL is in the ext folder along with php on my machine like this: C: php5 ext

  • So just by the message we identify that it is trying to search in the wrong path would be interesting to analyze it. But we have already identified that it is not a problem in CI but configuration of php

  • 1

    Otto, I managed to solve here was actually quite simple, it was only point in INI php the path of PHP extensions

  • If someone has this problem in the future with CI or another tool is the tip to look at the INI of PHP line: extension_dir= 'here you put the path of ext' In my case it was extension_dir = "C://php5/ext"

1 answer

4


It’s not a mistake in your application.

Probably talking the msqli driver in php In your php.ini and uncomment the following:

extension=php_mysqli.dll

If this extension is enabled and shows the error: Unable to locate the module of this extension

Check the PHP INI line with the instruction extension_dir this directory points the path of the Extensions to be loaded, just uncomment and put the path of the Extensions, follow as it appears in INI:

;Directory in which the loadable extensions (modules) reside.
;http://php.net/extension-dir
;extension_dir = "./"
;On windows:
extension_dir = "C://php//ext"

In Windows the path must always have // ex: c//php

Note: the commentary is represented by the point and comma( ";" )

  • I had already done this, it does not resolve, no matter what I do it displays the following message in the CLI: PHP Startup: Unable to load Dynamic library 'C: php ext php_mysqli.dll' - Could not find the specified module. in <b>Unknown</b> on line <b>0</b><br />

  • You have to have the Dll on your machine, I do not know how it is done in windows. But you have to install this extension in your php.

  • Checks if Voce has the php_mysqli.dll file in php/ext folder/

Browser other questions tagged

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