I am writing a simple test script to get my head around MySQLi prepared statements. This script will become the basis for a function that needs to be slightly dynamic in its handling of results. I need the fetch method to return as an array similar to how mysql_fetch_array() behaves.
I am aware some of these methods require mysqlnd. I have checked phpinfo. Mysqlnd is installed and present. See screenshot.
Please note, PDO is available on my server, but I need to get this script working with MySQLi at this time.! PDO will be researched later in this project.
require_once(__ROOT__ . '/config.inc.php');
$mysqli = new mysqli($config['db']['server'], $config['db']['username'], $config['db']['password'], $config['db']['database_name']);
$userid = 10;
$stmt = $mysqli->prepare("SELECT username, firstname, lastname FROM maj_user WHERE user_id < ?");
if ($stmt)
{
/* bind parameters for markers */
$stmt->bind_param('i', $userid);
/* execute query */
$stmt->execute();
$result = $stmt->get_result();
while ($row = $result->fetch_array())
{
echo 'We selected "' . $row['username'] . ' (' . $row['firstname'] . ' ' . $row['lastname'] . ')"' . PHP_EOL;
}
$result->close();
}
$mysqli->close();
The above code result in:
Fatal error: Call to undefined method mysqli_stmt::get_result() in /path/to/public_html/_test.php on line 25
Php.net says Mysqlnd needs to be present, but that clearly isn't the whole story. What else am I missing?
My PHP configs:
./configure' '--disable-fileinfo' '--enable-bcmath' '--enable-calendar' '--enable-ftp' '--enable-gd-native-ttf' '--enable-libxml' '--enable-pdo=shared' '--enable-sockets' '--prefix=/usr/local' '--with-apxs2=/usr/local/apache/bin/apxs' '--with-curl=/opt/curlssl/' '--with-freetype-dir=/usr' '--with-gd' '--with-imap=/opt/php_with_imap_client/' '--with-imap-ssl=/usr' '--with-jpeg-dir=/usr' '--with-kerberos' '--with-libdir=lib64' '--with-libxml-dir=/opt/xml2/' '--with-mcrypt=/opt/libmcrypt/' '--with-mysql=/usr' '--with-mysql-sock=/var/lib/mysql/mysql.sock' '--with-mysqli=/usr/bin/mysql_config' '--with-openssl=/usr' '--with-openssl-dir=/usr' '--with-pcre-regex=/opt/pcre' '--with-pdo-mysql=shared' '--with-pdo-sqlite=shared' '--with-pic' '--with-png-dir=/usr' '--with-xpm-dir=/usr' '--with-zlib' '--with-zlib-dir=/usr'
Installed PHP and MySQL packages:
cpanel-php54-Horde-Date-2.0.6-1.cp1142
cpanel-php54-Horde-Cache-2.2.1-1.cp1142
cpanel-php54-Horde-Kolab-Session-2.0.1-1.cp1142
cpanel-php54-Horde-Controller-2.0.1-1.cp1142
cpanel-php54-Date-Holidays-0.21.8-1.cp1142
cpanel-php54-SOAP-0.13.0-1.cp1142
cpanel-php54-Date-Holidays-Italy-0.1.1-1.cp1142
cpanel-php54-Net-Sieve-1.3.2-1.cp1142
cpanel-php54-Auth-SASL-1.0.6-1.cp1142
cpanel-php54-Horde-Mime-2.2.5-1.cp1142
cpanel-php54-horde-5.1.4-1.cp1142
cpanel-php54-Horde-Vfs-2.1.1-1.cp1142
cpanel-php54-Horde-Template-2.0.1-1.cp1142
cpanel-php54-horde-lz4-1.0.2-1.cp1142
cpanel-php54-Mail-1.2.0-1.cp1142
cpanel-php54-Date-Holidays-USA-0.1.1-1.cp1142
cpanel-php54-Date-Holidays-Japan-0.1.2-1.cp1142
cpanel-php54-PEAR-Command-Packaging-0.3.0-1.cp1142
cpanel-php54-Console-Table-1.1.5-1.cp1142
cpanel-php54-Horde-Data-2.0.4-1.cp1142
cpanel-php54-nag-4.1.2-1.cp1142
cpanel-php54-Horde-Auth-2.1.0-1.cp1142
cpanel-php54-Horde-Compress-2.0.4-1.cp1142
cpanel-php54-Horde-Text-Diff-2.0.2-1.cp1142
cpanel-php54-Horde-Http-2.0.4-1.cp1142
cpanel-php54-Horde-Secret-2.0.2-1.cp1142
cpanel-php54-Date-Holidays-Brazil-0.1.2-1.cp1142
cpanel-php54-Date-Holidays-Iceland-0.1.2-1.cp1142
cpanel-php54-Horde-Smtp-1.2.3-1.cp1142
cpanel-php54-Net-FTP-1.3.7-3.cp1142
cpanel-php54-Horde-Text-Filter-2.1.3-1.cp1142
cpanel-php54-Horde-Alarm-2.0.4-1.cp1142
cpanel-php54-Horde-SpellChecker-2.1.0-1.cp1142
cpanel-php54-Horde-Share-2.0.4-1.cp1142
cpanel-php54-Horde-Rdo-2.0.2-1.cp1142
cpanel-php54-Date-Holidays-Sweden-0.1.3-1.cp1142
cpanel-php54-Date-Holidays-Portugal-0.1.0-1.cp1142
cpanel-php54-Net-DNS2-1.3.1-1.cp1142
cpanel-php54-content-2.0.3-1.cp1142
cpanel-php54-Horde-Serialize-2.0.2-1.cp1142
cpanel-php54-Horde-Notification-2.0.1-1.cp1142
cpanel-php54-Horde-Text-Flowed-2.0.1-1.cp1142
cpanel-php54-Horde-Routes-2.0.2-1.cp1142
cpanel-php54-Horde-Queue-1.1.1-1.cp1142
cpanel-php54-Horde-Perms-2.1.1-1.cp1142
cpanel-php54-Horde-Feed-2.0.1-1.cp1142
cpanel-php54-Horde-Cli-2.0.4-1.cp1142
cpanel-php54-Mail-Mime-1.8.3-1.cp1142
cpanel-php54-kronolith-4.1.3-3.cp1142
cpanel-php54-Date-Holidays-SanMarino-0.1.1-1.cp1142
cpanel-php54-Date-Holidays-Germany-0.1.2-1.cp1142
cpanel-php54-Date-Holidays-Russia-0.1.0-1.cp1142
cpanel-php54-Date-Holidays-EnglandWales-0.1.5-1.cp1142
cpanel-php54-Cache-1.5.6-1.cp1142 cpanel-php54-XML-SVG-1.1.0-1.cp1142
cpanel-php54-Net-UserAgent-Detect-2.5.2-1.cp1142
cpanel-php54-Horde-Prefs-2.5.0-1.cp1142
cpanel-php54-Horde-Form-2.0.5-1.cp1142
cpanel-php54-webmail-5.1.1-1.cp1142
cpanel-php54-Horde-Translation-2.0.1-1.cp1142
cpanel-php54-Horde-Nls-2.0.3-1.cp1142
cpanel-php54-Horde-Stream-Filter-2.0.2-1.cp1142
cpanel-php54-Horde-Compress-Fast-1.0.2-1.cp1142
cpanel-php54-Net-IMAP-1.1.2-1.cp1142
cpanel-php54-Horde-Pdf-2.0.3-1.cp1142
cpanel-php54-Horde-Stream-Wrapper-2.0.1-1.cp1142
cpanel-php54-Horde-Image-2.0.5-1.cp1142
cpanel-php54-Horde-Service-Facebook-2.0.5-1.cp1142
cpanel-php54-XML-Serializer-0.20.2-1.cp1142
cpanel-php54-Date-Holidays-Norway-0.1.2-1.cp1142
cpanel-php54-Date-Holidays-Croatia-0.1.1-1.cp1142
cpanel-php54-Date-Holidays-PHPdotNet-0.1.2-1.cp1142
cpanel-php54-zendopt-6.0.0-1.cp1142
cpanel-php54-File-Find-1.3.2-1.cp1142
cpanel-php54-Horde-Itip-2.0.5-1.cp1142
cpanel-php54-Horde-Rpc-2.1.0-1.cp1142
cpanel-php54-timeobjects-2.0.4-1.cp1142
cpanel-php54-Horde-Util-2.3.0-1.cp1142
cpanel-php54-Horde-Browser-2.0.4-1.cp1142
cpanel-php54-Horde-LoginTasks-2.0.2-1.cp1142
cpanel-php54-Horde-Tree-2.0.2-1.cp1142
cpanel-php54-Net-SMTP-1.6.2-1.cp1142
cpanel-php54-Horde-Kolab-Format-2.0.4-1.cp1142
cpanel-php54-Horde-Log-2.0.1-1.cp1142
cpanel-php54-Horde-History-2.2.0-1.cp1142
cpanel-php54-5.4.23-4.cp1142
cpanel-php54-Horde-Service-Twitter-2.1.1-1.cp1142
cpanel-php54-XML-Parser-1.3.4-1.cp1142
cpanel-php54-Date-Holidays-Denmark-0.1.3-1.cp1142
cpanel-php54-Date-Holidays-Australia-0.2.1-1.cp1142
cpanel-php54-Date-Holidays-Ukraine-0.1.2-1.cp1142
cpanel-php54-Date-Holidays-Romania-0.1.2-1.cp1142
cpanel-php54-File-1.4.1-1.cp1142 cpanel-php54-ioncube-4.5.2-1.cp1142
cpanel-php54-Console-Color-1.0.3-1.cp1142
cpanel-php54-Horde-Mime-Viewer-2.0.5-1.cp1142
cpanel-php54-Horde-Dav-1.0.2-1.cp1142
cpanel-php54-ingo-3.1.2-3.cp1142 cpanel-php54-MDB2-2.4.1-2.cp1142
cpanel-php54-Horde-Url-2.2.1-1.cp1142
cpanel-php54-Horde-Autoloader-2.0.1-1.cp1142
cpanel-php54-Horde-Xml-Element-2.0.1-1.cp1142
cpanel-php54-Horde-HashTable-1.1.0-1.cp1142
cpanel-php54-Horde-Imsp-2.0.5-1.cp1142
cpanel-php54-Horde-View-2.0.3-1.cp1142
cpanel-php54-Horde-Lock-2.1.0-1.cp1142
cpanel-php54-Horde-Crypt-Blowfish-1.0.2-1.cp1142
cpanel-php54-Net-URL-1.0.15-1.cp1142
cpanel-php54-Services-Weather-1.4.7-1.cp1142
cpanel-php54-Date-Holidays-UNO-0.1.3-1.cp1142
cpanel-php54-Date-Holidays-Austria-0.1.5-1.cp1142
cpanel-php54-Date-Holidays-Venezuela-0.1.1-1.cp1142
cpanel-php54-sourceguardian-8.3-1.cp1142
cpanel-php54-XML-RPC-1.5.5-1.cp1142 cpanel-php54-DB-1.7.14-1.cp1142
cpanel-php54-Horde-Mail-2.1.1-1.cp1142
cpanel-php54-Horde-Timezone-1.0.3-1.cp1142
cpanel-php54-mnemo-4.1.1-1.cp1142
cpanel-php54-Horde-Crypt-2.2.2-1.cp1142
cpanel-php54-HTML-Template-IT-1.3.0-2.cp1142
cpanel-php54-imp-6.1.4-4.cp1142
cpanel-php54-Horde-Exception-2.0.4-1.cp1142
cpanel-php54-Net-Socket-1.0.14-1.cp1142
cpanel-php54-Horde-Editor-2.0.3-1.cp1142
cpanel-php54-Horde-Support-2.1.1-1.cp1142
cpanel-php54-Horde-ElasticSearch-1.0.2-1.cp1142
cpanel-php54-Date-Holidays-Finland-0.1.2-1.cp1142
cpanel-php54-Date-Holidays-Ireland-0.1.3-1.cp1142
cpanel-php54-Log-1.12.7-1.cp1142
cpanel-php54-Horde-SyncMl-2.0.3-1.cp1142
cpanel-php54-Horde-ListHeaders-1.0.1-1.cp1142
cpanel-php54-Horde-Group-2.0.2-1.cp1142
cpanel-php54-Horde-Stream-1.3.0-1.cp1142
cpanel-php54-Horde-Argv-2.0.7-1.cp1142
cpanel-php54-Horde-Db-2.0.4-1.cp1142
cpanel-php54-Horde-SessionHandler-2.2.3-1.cp1142
cpanel-php54-Date-Holidays-Slovenia-0.1.2-1.cp1142
cpanel-php54-Date-Holidays-Turkey-0.1.1-1.cp1142
cpanel-php54-Horde-Core-2.8.0-1.cp1142
cpanel-php54-Horde-Yaml-2.0.2-1.cp1142
cpanel-php54-Date-1.4.7-2.cp1142
cpanel-php54-Horde-Token-2.0.4-1.cp1142
cpanel-php54-Horde-Css-Parser-1.0.1-1.cp1142
cpanel-php54-Horde-Xml-Wbxml-2.0.1-1.cp1142
cpanel-php54-Horde-Date-Parser-2.0.2-1.cp1142
cpanel-php54-Date-Holidays-Serbia-0.1.0-1.cp1142
cpanel-php54-Date-Holidays-Czech-0.1.0-1.cp1142
cpanel-php54-File-Fstab-2.0.3-1.cp1142
cpanel-php54-Text-Figlet-1.0.2-1.cp1142
cpanel-php54-Horde-Icalendar-2.0.7-1.cp1142
cpanel-php54-trean-1.0.3-1.cp1142
cpanel-php54-HTTP-Request-1.4.4-2.cp1142
cpanel-php54-Horde-Role-1.0.1-4.cp1142
cpanel-php54-Horde-Injector-2.0.2-1.cp1142
cpanel-php54-Horde-Constraint-2.0.1-1.cp1142
cpanel-php54-Horde-Oauth-2.0.1-1.cp1142
cpanel-php54-Date-Holidays-Netherlands-0.1.3-1.cp1142
cpanel-php54-Date-Holidays-Spain-0.1.3-1.cp1142
cpanel-php54-HTTP-WebDAV-Server-1.0.0RC8-1.cp1142
cpanel-php54-Horde-Imap-Client-2.15.3-1.cp1142
cpanel-php54-turba-4.1.2-1.cp1142 cpanel-php54-HTTP-1.4.1-2.cp1142
cpanel-mysql-5.1.73-1.cp1136 cpanel-mysql-libs-5.1.73-1.cp1136
cpanel-perl-514-DBD-mysql-4.027-2.cp1146
mysqli_stmt::get_result
is only available in PHP 5.3 or newer. – Gerald Schneidermysqli
itself (which probably comes right before themysqlnd
section). It should show whether the client library is mysqlnd or mysql (for some reason) I'm not sure it's even possible for both to be loaded though. The <5.3 issue is more likely. – Michael Berkowski