PHP Connect to MySQL
Before we can access data in the MySQL database, we need to be able to connect to the server.
Ways to connect:
- MySQLi (Object-Oriented) - MySQL Improved extension
- MySQLi (Procedural)
- PDO (PHP Data Objects) - Works with 12 different database systems
Try It Yourself
Edit the code below and click Run to see the result live.