I have a couple of PHP8 projects running on shared hosting which use mysql features like get_result(). Overnight everything has stopped working and get_result() is now reported as an undefined function. As per Call to undefined method mysqli_stmt::get_result I suspect mysqlnd is not installed/enabled.
Example code:
$sql = 'SELECT * FROM projects WHERE projects.id = ? LIMIT 1';
$stmt = mysqli_prepare($db, $sql);
$stmt->bind_param("i", $project_id);
$stmt->execute();
$result = $stmt->get_result();
Error:
Fatal error: Uncaught Error: Call to undefined method mysqli_stmt::get_result()
With this code from How to know if MySQLnd is the active driver? I've apparently established mysqlnd is not being used and libmysqlclient is being used.
<?php
if (function_exists('mysql_connect')) {
echo "- MySQL <b>is installed</b>.<br>";
} else {
echo "- MySQL <b>is not</b> installed.<br>";
}
if (function_exists('mysqli_connect')) {
echo "- MySQLi <b>is installed</b>.<br>";
} else {
echo "- MySQLi <b>is not installed</b>.<br>";
}
if (function_exists('mysqli_get_client_stats')) {
echo "- MySQLnd driver is being used.<br>";
} else {
echo "- libmysqlclient driver is being used.<br>";
}
Result:
- MySQL is not installed.
- MySQLi is installed.
- libmysqlclient driver is being used.
The hosting provider says nothing changed, but my code all started failing within the last 24hrs without any changes by me. The PHP build date via phpinfo is 7 days ago. The PHP version is 8.0.10. The php configure command does contain '--with-mysql=mysqlnd'
but that is the only reference to mysqlnd in the phpinfo output.
Full configure command:
'./configure' '--build=x86_64-linux-gnu' '--prefix=/usr' '--includedir=${prefix}/include' '--mandir=${prefix}/share/man' '--infodir=${prefix}/share/info' '--sysconfdir=/etc' '--localstatedir=/var' '--disable-silent-rules' '--libdir=${prefix}/lib/x86_64-linux-gnu' '--libexecdir=${prefix}/lib/x86_64-linux-gnu' '--disable-maintainer-mode' '--disable-dependency-tracking' '--program-suffix=8.0' '--libdir=/usr/lib/php8.0' '--with-config-file-path=/etc/php8.0' '--with-pear=/usr/lib/php8.0' '--bindir=/usr/bin' '--includedir=/usr/include' '--with-zlib' '--enable-debug=no' '--enable-safe-mode=no' '--enable-discard-path=no' '--with-gd' '--with-png-dir' '--enable-track-vars' '--with-db' '--with-gdbm' '--enable-force-cgi-redirect' '--with-ttf' '--enable-ftp' '--with-mcrypt' '--enable-memory-limit' '--enable-calendar' '--enable-wddx' '--enable-bcmath' '--enable-gd-imgstrttf' '--enable-shmop' '--with-openssl' '--with-dom' '--with-dom-xslt' '--with-dom-exslt' '--with-imap' '--with-curl' '--with-iconv' '--with-freetype-dir' '--with-bz2' '--with-gettext' '--enable-exif' '--enable-mbstring=all' '--with-kerberos' '--with-sqlite' '--with-imap-ssl' '--with-libxml-dir' '--with-xsl' '--with-xslt-sablot' '--with-jpeg-dir' '--with-tidy' '--enable-soap' '--enable-xslt' '--enable-sqlite-utf8' '--enable-zip' '--enable-intl' '--with-mysqli=/usr/bin/mysql_config' '--with-pdo-mysql=/usr/bin/mysql_config' '--with-mysql=mysqlnd' '--with-gmp' '--with-webp-dir' '--with-sodium' '--with-password-argon2' '--with-zip' '--enable-gd' '--with-external-gd' '--with-freetype' '--with-jpeg' '--with-webp' '--with-xpm' 'build_alias=x86_64-linux-gnu'
Is there anything else I can do to diagnose this, or challenge the host provider's configuration? Is it possible mysqlnd was never enabled and my code was able to work (and broke) for a different reason?
Update: The hosting company are absolutely adamant that nothing has changed and mysqlnd is enabled, despite all the clues above. Is there anything else that would explain this?