PHP-MYSQL-001
mysql_query()
mysql_* PHP functions
mysql_* was removed from PHP 7. Joomla 4 will not run on PHP that still has it. Direct mysql_query also bypasses Joomla's prefix and ACL.
mysql_query() → Joomla DatabaseInterface / mysqli / PDO
What you will see
- Call to undefined function mysql_query()
- Call to undefined function mysql_connect()
Symptoms people search
undefined function mysql_query
Replace this code
Swap mysql_query() for Joomla DatabaseInterface / mysqli / PDO.
Joomla 3
Remove or stop calling this
$res = mysql_query('SELECT * FROM jos_users');Joomla 4 / 6
Use this instead
$db = $this->getDatabase();
$query = $db->getQuery(true)->select('*')->from($db->quoteName('#__users'));
$db->setQuery($query);
$rows = $db->loadObjectList();How to fix it
- 1Replace mysql_* with the Joomla database API and bound parameters.
Also known as
mysql_query · mysql_connect · mysql_fetch
There is no 1:1 swap for this one. The architecture changed. If you cannot rewrite it, Infyways can.
Related issues
- Joomla 3 → 4PHP
jimport() autoloader calls
jimport('joomla.filesystem.file') → use Joomla\CMS\Filesystem\File;
- Joomla 3 → 4PHP
DS path constant
DS → DIRECTORY_SEPARATOR or /
- Joomla 3 → 4PHP
JPATH_PLATFORM
JPATH_PLATFORM → Do not use — autoload instead
- Joomla 3 → 4SQL / schema
MyISAM engine in install SQL
ENGINE=MyISAM → ENGINE=InnoDB
- Joomla 3 → 4PHP
each() / create_function() / ereg / split
each($array) → foreach / closures / preg_*
- Joomla 4 → 5PHP
Dynamic PHP properties (PHP 8.2+)
$this->foo = 1 on an untyped class → Declare the property or use AllowDynamicProperties