Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $hostname = "localhost";
- $username = "mysqluser";
- $password = "mysqlpass";
- $database = "mysqldbname";
- $strtedAt = microtime(true);
- try {
- $conn = new PDO("mysql:host=$hostname;dbname=$database", $username, $password);
- // set the PDO error mode to exception
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- echo "Connected successfully <br>";
- }
- catch(PDOException $e)
- {
- echo "Connection failed: " . $e->getMessage();
- }
- $endedAt = microtime(true);
- $msc = $endedAt - $strtedAt;
- echo "Time to mysql connect: " . $msc . ' s'; // in seconds
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement