Interfacing MySQL with PHP on Shared UW Hosting
IT Connect > Web > Publishing > Using MySQL > Interfacing With PHP
- On This Page
- MySQL Scripting With PHP
- Resources
Note: You must set up your MySQL server before you can retrieve data from it.
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 particuar way to structure your MySQLi object in order to properly connect to your MySQL server.
$mysqli_connection = new MySQLi('your_host.u.washington.edu', 'root', 'your_password', 'your_db, your_port);
if($mysqli_connection->connect_error){
echo "Not connected, error: ".$mysqli_connection->connect_error;
}
else{
echo "Connected."
}


