Advertisement
Guest User

Untitled

a guest
May 8th, 2016
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. <?php
  2.  
  3. &hostname = "dbtrain.im.uu.se";
  4. &database = "lab1";
  5. &username = "db_train270";
  6. &password = "vdgfgf";
  7.  
  8. $link = mysql_connect($hostname, $username, $password);
  9. if (!$link) {
  10. die('Connection failed: ' . mysql_error());
  11. }
  12. else{
  13. echo "Connection to MySQL server " .$hostname . " successful!
  14. " . PHP_EOL;
  15. }
  16.  
  17. $db_selected = mysql_select_db($database, $link);
  18. if (!$db_selected) {
  19. die ('Can\'t select database: ' . mysql_error());
  20. }
  21. else {
  22. echo 'Database ' . $database . ' successfully selected!';
  23. }
  24.  
  25. mysql_close($link);
  26.  
  27. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement