darkmist

mysqli_connect

Nov 13th, 2016
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.56 KB | None | 0 0
  1. <?php
  2. // If using Docker, this code has been tested with "jorge07/alpine-php:7" image.
  3.  
  4. $link = mysqli_connect("107.170.222.199", "donstringham", "1234pass", "final");
  5.  
  6. if (!$link) {
  7.     echo "Error: Unable to connect to MySQL." . PHP_EOL;
  8.     echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
  9.     echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;
  10.     exit;
  11. }
  12.  
  13. echo "Success: A proper connection to MySQL was made! The database is great." . PHP_EOL;
  14. echo "Host information: " . mysqli_get_host_info($link) . PHP_EOL;
  15.  
  16. mysqli_close($link);
Add Comment
Please, Sign In to add comment