PHP and MySQL with PDO and MySQLi

PHP applications can access MySQL through PDO_MySQL or MySQLi. The original PHP mysql_* extension was deprecated in PHP 5.5 and removed in PHP 7, so code such as mysql_connect() and mysql_query() is historical and must not be used in current applications.

Migration note: these long-standing tutorial URLs are preserved for learners who encounter old code. Each function page now explains the legacy API and points to a current PDO/MySQLi replacement rather than presenting removed functions as executable modern PHP.

For new applications, start with PDO or MySQLi. Use prepared statements whenever values come from users or other untrusted input.

Legacy function to current API map

Historical topicCurrent approachTutorial
mysql_connect() / mysql_pconnect()new PDO(...) or new mysqli(...)Connections
mysql_close()Release PDO reference or call mysqli::close()Closing connections
mysql_query()PDO::query(), PDO::prepare(), mysqli::query() or prepared statementsExecuting queries
mysql_num_rows()COUNT(*), fetched-row count, or mysqli_result::$num_rowsCounting rows
mysql_fetch_row()PDOStatement::fetch(PDO::FETCH_NUM) or mysqli_result::fetch_row()Fetching rows
mysql_error()PDO exceptions / errorInfo() or MySQLi exceptionsError messages
mysql_errno()SQLSTATE / driver code or mysqli::$errnoError codes
mysql_list_tables()SHOW TABLES / INFORMATION_SCHEMAList tables

More PHP/MySQL topics




Subscribe to our YouTube Channel here



plus2net.com




SQL Video Tutorials










✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer