• I do the following so you can reproduce it in about a minute:

    a) mkdir wordpress
    b) cd wordpress
    c) git clone https://github.com/WordPress/WordPress.git .
    d) docker run -p 127.0.0.1:3306:3306 –name some-mariadb -e MARIADB_ROOT_PASSWORD=PASSWORD -d mariadb:latest
    e) docker run -d -p 8082:80 –mount type=bind,source=”$(pwd)”,target=/var/www/html php:apache


    – I connect via dbgate to the datebase and create an empty database “wordpress01”
    – I create a file info.php and phpinfo shows in the browser that mysqlnd is installed
    – I change the wp-config.php file and load the site on localhost:8082 but get

    “Uncaught Error: Call to undefined function mysql_connect() in /var/www/html/wp-includes/wp-db.php:1771”

    hmm

Viewing 3 replies - 1 through 3 (of 3 total)
  • Dion

    (@diondesigns)

    That error message basically means that WordPress wasn’t able to use mysqli to connect to the database, so it instead tried to use mysql, which doesn’t exist in PHP7+. (It’s old/obsolete code that in 2021 has no business being in WordPress, but I digress.) Check your PHP configuration and insure the mysqli extension is available.

    Your issue isn’t a WordPress problem, it’s a Docker configuration problem. So if the above doesn’t help, I suggest asking your question where Docker folks hang out, perhaps on stackexchange. You can also contact Docker support:

    https://hub.docker.com/support/contact/

    Thread Starter cogmios

    (@cogmios)

    In /usr/local/etc/php/php.ini extension=mysqli is uncommented | phpinfo shows the lib mysqlnd 8.0.11

    Im using the out of the box images from mariadb and php org above

    Probably can reduce it to

    <?php
    
    if ( function_exists( 'mysqli_connect' ) ) 
    {
    	echo "exists";
    }
    
    Over to... stackexchange...
    else
    {
    	echo "does not exist";
    }
    ?>
    • This reply was modified 3 years, 1 month ago by cogmios.
    • This reply was modified 3 years, 1 month ago by cogmios.
    • This reply was modified 3 years, 1 month ago by cogmios.
    • This reply was modified 3 years, 1 month ago by cogmios.
    • This reply was modified 3 years, 1 month ago by cogmios.
    • This reply was modified 3 years, 1 month ago by cogmios.
    Thread Starter cogmios

    (@cogmios)

    I solved this by recompiling PHP on the image WITH ‘–with-mysqli=mysqlnd’

    See: https://superuser.com/questions/1678318/php-extension-mysqli-installed-but-calling-it-gives-an-error/1678396#1678396

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Call to undefined function mysql_connect() in /var/www/html/wp-includes/wp-db.ph’ is closed to new replies.