Fatal Error: Call to Undefined Function Mysqli_Connect()

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.

  1. Copy php.ini-development into php.ini and place it somewhere.

  2. Find the line

;extension=mysqli

and uncomment it (remove the semicolon from the beggining)


  1. Run your server. If php.ini is placed not where php.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



Leave a reply



Submit