Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $link = mysqli_connect("127.0.0.1", "user", "password", "database");
- if (!$link) {
- echo "Error: Unable to connect to MySQL.";
- exit;
- }
- echo "Success: Connection to MySQL ready.";
- mysqli_close($link);
- ?>
- <?php
- /* Connect to a MySQL database using driver invocation */
- $dsn = 'mysql:dbname=testdb;host=127.0.0.1';
- $user = 'dbuser';
- $password = 'dbpass';
- try {
- $dbh = new PDO($dsn, $user, $password);
- } catch (PDOException $e) {
- echo 'Connection failed: ' . $e->getMessage();
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement