PHP 7.4.1 Uncaught Error: Call to undefined function mysqli_connect()
First you need to have a php.ini
somewhere.
Usually in the directory with php you have two files php.ini-development
and php.ini-production
- they are examples of php.ini
with some recommended settings.
Copy
php.ini-development
intophp.ini
and place it somewhere.Find the line
;extension=mysqli
and uncomment it (remove the semicolon from the beggining)
- Run your server. If
php.ini
is placed not wherephp.exe
is, then pass the path to it in the command line after-c
option:
D:\path\to\php\php.exe -S localhost:8080 -c D:\path\to\ini\file\php.ini ...
Call to undefined function mysqli_connect()
In Dockerfile you need add mysqli extension:
FROM php:7.3-fpm
# Update system core
RUN apt update && apt install -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev libxml2-dev libcurl4-gnutls-dev
RUN docker-php-ext-install -j$(nproc) mysqli \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install -j$(nproc) gd
# Start PHP-FPM
CMD ["php-fpm"]
Call to undefined function mysqli_connect() issue
Check if mysqli library is enabled in your php.ini.
Also consider using PDO instead, it is better and not tied to MySQL.
Related Topics
Reference - What Does This Error Mean in PHP
How to Flatten a Multidimensional Array
Call to a Member Function on a Non-Object
How to Iterate Utf-8 String in PHP
How to Deal With MySQLi Problems - MySQLi_Fetch_Array(): Argument #1 Must Be of Type MySQLi_Result
How to Sort a Multidimensional Array in PHP
Getting Error in Console:Failed to Load Resource: Net::Err_Connection_Reset
How to Get PHP Errors to Display
How to Get the Client Ip Address in PHP
How Does PHP 'Foreach' Actually Work
Display Data from Database to Dropdown Codeigniter
How to Sort Arrays and Data in PHP
Warning: Preg_Replace(): Unknown Modifier
How to Get a Youtube Video Thumbnail from the Youtube API
MySQL Great Circle Distance (Haversine Formula)