×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: PHP
Posted by: Lionel Crasson
Added: Sep 5, 2012 11:25 AM
Views: 33
Tags: no tags
  1. --------------------------
  2. constants.php
  3. --------------------------
  4.  
  5. <?php
  6.  
  7. //database Constants
  8. define("DB_SERVER","____________");
  9. define("DB_USER","_________");
  10. define("DB_PASS","__________");
  11. define("DB_NAME","___________");
  12. ?>
  13.  
  14. ----------------------------------
  15. connection.php
  16. ---------------------------------
  17. <?php
  18. require("constants.php");
  19. //1.Create a database connection
  20. $connection = mysql_connect("DB_SERVER","DB_USER","DB_PASS");
  21. if(!connection){
  22.         die("database connection failed:".mysql_error());
  23. }
  24. //2.Select a database to use
  25. $db_select = mysql_select_db("DB_NAME";$connection);
  26. if(!$db_select){
  27.         die ("Database selection failed:".mysql_error());
  28. }
  29. ?>
  30.  
  31.