Advertisement
bu2chlc

database connection info (DRY)

Nov 16th, 2019
336
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.58 KB | None | 0 0
  1. <?php
  2.     // the database credentials and connection are stored in this file and included in each php page
  3.  
  4.     // db connection credentials
  5.     $db_user="imageuser";
  6.     $db_pass="password";
  7.     $db_host="localhost";
  8.     $db_name="images";
  9.  
  10.     $conn= mysqli_connect($db_host, $db_user, $db_pass, $db_name);
  11.     if($conn->connect_errno)
  12.     {
  13.       // if there is a connection error, print the error
  14.       printf("Connect failed: %s\n", $conn->connect_error);
  15.      
  16.       // handle the error or even die, why continue if there is no db connection.
  17.       die();
  18.     }
  19.     ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement