IT Connect
Your connection to information technology at the UW

Connecting to MySQL using PHP

MySQL Scripting With PHP

Connecting and interacting with a MySQL database using PHP or any other language is a fairly complex topic. This code example provides a simple way to test your connection and provides one particular way to structure your MySQLi object in order to properly connect to your MySQL server.

$mysqli_connection = new MySQLi('', 'root', 'your_password', 'your_db', your_port);
   echo "Not connected, error: ".$mysqli_connection->connect_error;
   echo "Connected.";