phpMyAdmin导入功能count报错及修改后500错误求助
Hey there, let's work through this phpMyAdmin issue step by step—since you can't upgrade PHP, we'll focus on safe, compatible fixes to get you back up and running, plus an emergency export option if you need it right now.
Step 1: Rollback the Broken Code Change to Fix the 500 Error
First, let's undo the edit you made to ./libraries/plugin_interface.lib.php that triggered the 500 internal server error. That direct array cast likely introduced an unexpected type conflict.
- Access your server via SSH or a file manager
- Navigate to the phpMyAdmin libraries directory (typically
/usr/share/phpmyadmin/libraries/on Ubuntu 18.04) - Open
plugin_interface.lib.phpand revert the line you modified back to its original state:if ($options != null && count($options) > 0) - Restart Apache to apply the rollback:
sudo systemctl restart apache2
This should bring phpMyAdmin back online immediately.
Step 2: Fix the Original count() Warning (PHP 7.2 Compatibility)
The initial warning happens because PHP 7.2 tightened rules for the count() function—it only accepts arrays or objects that implement the Countable interface. The $options variable might sometimes be a non-countable value (like null or a scalar). Instead of the problematic array cast, use a safer, version-compatible check:
- Edit
plugin_interface.lib.phpagain, replacing the line with this:if ($options != null && (is_array($options) || $options instanceof Countable) && count($options) > 0)
This first verifies $options is either an array or a countable object before calling count(), which aligns with PHP 7.2's requirements without breaking the code.
- Restart Apache once more to apply the fix:
sudo systemctl restart apache2
Step 3: Emergency Database Export Alternative (If phpMyAdmin Still Acts Up)
If you need to export your database immediately and don't want to mess with phpMyAdmin code further, use the command-line mysqldump tool—it's reliable, bypasses phpMyAdmin's PHP compatibility issues, and works perfectly with your MariaDB 10.1 setup:
- Run this command, replacing the placeholders with your actual database credentials:
mysqldump -u [your_db_username] -p [your_database_name] > /path/to/save/exported_database.sql - When prompted, enter your database password.
- The SQL export file will be saved to the path you specified—you can download it via SFTP or your server's file manager.
内容的提问来源于stack exchange,提问作者John Durchak

