Guest User

Untitled

a guest
Oct 5th, 2018
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. <?php
  2. /*Program: mysql_test.php
  3. *Desc: Connects to MySQL Server and
  4. * outputs settings.
  5. */
  6. echo "<html>
  7. <head><title>Test MySQL</title></head>
  8. <body>";
  9. $host = "localhost";
  10. $user = "root";
  11. $password = " ";
  12.  
  13. $cxn = mysqli_connect($host, $user, $password);
  14. $sql = "SHOW DATABASES";
  15. $result = mysqli_query($cxn, $sql);
  16. if($result == false)
  17. {
  18. echo "<h4>Error: ".mysqli_error($cxn)."</h4>";
  19. }
  20. else
  21. {
  22. if(mysqli_num_rows($result) < 1)
  23. {
  24. echo "<p>No current databases</p>";
  25. }
  26. {
  27. echo "<ol>";
  28. while($row = mysqli_fetch_row($result))
  29. {
  30. echo "<li>$row[0]</li>";
  31. }
  32. echo "</ol>";
  33. }
  34. }
  35. ?>
  36. </body></html>
Add Comment
Please, Sign In to add comment