MySqli_connect() with Docker


Following through the PHP Novice To Ninja 7 book using Docker. I’m also trying to experiment with some old tutorials I’ve found that use mysqli_connect(). I can’t get it to work on Docker

Fatal error: Uncaught Error: Call to undefined function mysqli_connect() in /websites/shoppingcart/public/Cart.php on line 5

I have put the following in my Dockerfile:

RUN docker-php-ext-install pdo pdo_mysql
RUN docker-php-ext-install mysqli && docker-php-ext-enable mysqli

and tried using the following to confirm its absense:

if (!function_exists(‘mysqli_init’) && !extension_loaded(‘mysqli’)) {
echo ‘We don't have mysqli!!!’;

The PDO connection works fine

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.