Advertisement
Guest User

Untitled

a guest
Feb 21st, 2016
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. if(!ConnectionManager::getDataSource('default'))
  2. {
  3. die(); //this will be a message instead
  4. }
  5.  
  6. <?php
  7. $filePresent = true;
  8. if (!file_exists(CONFIGS.'database.php')):
  9. echo '<span class="notice-failure">Database configuration file is not present. Please contact admin@website</span>';
  10. $filePresent = false;
  11. endif;
  12. if ($filePresent!=false):
  13. uses('model' . DS . 'connection_manager');
  14. $db = ConnectionManager::getInstance();
  15. @$connected = $db->getDataSource('default');
  16. if (!$connected->isConnected()):
  17. echo '<p><span class="notice-failure">Not able to connect to the database. Please contact admin@website</span></p>';
  18. endif;
  19. endif;
  20. ?>
  21.  
  22. $servername = "localhost";
  23. $username = "username";
  24. $password = "password";
  25.  
  26. // Create connection
  27. $conn = new mysqli($servername, $username, $password);
  28.  
  29. // Check connection
  30. if ($conn->connect_error) {
  31. die("Connection failed: " . $conn->connect_error);
  32. }
  33. echo "Connected successfully";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement