LexXy :
In this code must be an error due to empty arguments in the mysqli_connect
function. But browser display different error. As I know mysqli_connect
function installed by default. Where is the problem or my mistake? How I can fix it?
Dockerfile
FROM php:fpm
# Update system core
RUN apt update -y && apt upgrade -y
# Start PHP-FPM
CMD ["php-fpm"]
index.php
<?php mysqli_connect('', '', '', '', '', ''); ?>
Error in browser:
Fatal error: Uncaught Error: Call to undefined function mysqli_connect() in /var/www/index.php:3 Stack trace: #0 {main} thrown in /var/www/index.php on line 3
Dmitry :
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"]