gpt4 book ai didi

php - 调用未定义的函数mysqli_connect()

转载 作者:行者123 更新时间:2023-12-01 15:45:18 25 4
gpt4 key购买 nike

由于mysqli_connect函数中的参数为空,因此此代码中必须是错误。但是浏览器显示不同的错误。据我所知mysqli_connect函数默认安装。问题或我的错误在哪里?我该如何解决?

Docker文件

FROM php:fpm

# Update system core
RUN apt update -y && apt upgrade -y

# Start PHP-FPM
CMD ["php-fpm"]

index.php
<?php mysqli_connect('', '', '', '', '', ''); ?>

浏览器错误:
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

最佳答案

在Dockerfile中,您需要添加mysqli扩展名:

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"]

关于php - 调用未定义的函数mysqli_connect(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60415725/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com