Advertisement
mhdew

database connection

Aug 26th, 2020
2,155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.67 KB | None | 0 0
  1. <?php
  2.     include_once 'practice3.php';  //add the path of the file containing database connection code
  3. ?>
  4.  
  5. <!doctype html>
  6. <html lang="en">
  7. <head>
  8.     <meta charset="utf-8">
  9.     <title>Exam Practice 1</title>
  10. </head>
  11. <body>
  12.     Hello World<br>
  13.  
  14.     <?php
  15.         // database connection check
  16.         if($conn){
  17.             echo "Database connected";
  18.         }
  19.         else{
  20.             echo "Connection Error";
  21.         }
  22.     ?>
  23. </body>
  24. </html>
  25.  
  26.  
  27. <!-- put this code into another file -->
  28. <?php
  29.         // database connection code
  30.         $dbServerName="localhost";
  31.         $dbUserName="root";
  32.         $dbPassword= "";
  33.         $dbName="test3";
  34.  
  35.         $conn=mysqli_connect($dbServerName,$dbUserName,$dbPassword,$dbName);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement