Distinguish an absent API from a refused connection
An undefined mysql_connect function on PHP 7 or later is consistent with use of the removed mysql extension. That differs from a supported database client reporting access denied or connection refused. Record the PHP runtime and exact redacted error before changing credentials or database permissions.
- Check whether the code uses other mysql_* calls.
- Confirm which supported extension exists on the target host.
- Do not solve this by returning a public site to an unsupported runtime without an agreed security decision.
Migrate a database boundary, not one function
MySQLi and PDO_MySQL are supported replacements, but their connection, query, result and error interfaces differ. A blanket name substitution does not account for argument order, explicit connection objects or prepared statements. Review the application's shared database wrapper first; centralising the change can be safer than inconsistent edits across pages.
- Inventory reads, inserts, updates and transactions.
- Define handling for a failed connection and a failed query.
- Keep user input bound as parameters rather than concatenating it into SQL.
Use synthetic records to prove behaviour
Test a representative read, insert, update and failure path on an isolated database with disposable records. Check affected row counts, character encoding and the expected application messages. PHP 8's PDO exception default can expose a previously silent failure, so test the error path as well as successful queries.
- Verify no extra records are written by repeated requests.
- Review the complete changed-file list and database API calls.
- Keep production dumps and credentials out of the enquiry and test workspace.
Scope boundary
This repair is an API migration for the agreed application boundary. A schema redesign, hosting move, lost-data recovery or every unrelated PHP incompatibility is different work. Request a quote with runtime versions and the redacted error; safe private code access follows an agreed scope.
Sources and limits
- PHP: mysql installation Checked 2026-10-10.
- mysql was deprecated in PHP 5.5 and removed in PHP 7.0.
- MySQLi or PDO_MySQL should replace it.
- PHP: PHP 8.0 incompatibilities Checked 2026-10-10.
- PDO default error handling becomes exceptions in PHP 8.0.