Guest User

Untitled

a guest
May 15th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. <?php
  2. /**
  3. * @file src/mysql/connect.php
  4. * @brief Connect to the database
  5. * @author Paul Barbu
  6. *
  7. * @ingroup mysqlConn
  8. *
  9. * This file returns a link with the connection details for further use with
  10. * mysqli_query()
  11. *
  12. * The link returned will be usable in other modules as $feedback_pre['key']
  13. *
  14. * where 'key' is the key of the mysql module in the preprocess part
  15. */
  16.  
  17. /**
  18. * @defgroup mysqlConn Handle a MySQL connection
  19. */
  20.  
  21. /**
  22. * MySQL host to connect to
  23. */
  24. <<<<<<< Updated upstream
  25. defined('MYSQL_HOST') or define('MYSQL_HOST', '');
  26. /**
  27. * Login name for MySQL
  28. */
  29. defined('MYSQL_USER') or define('MYSQL_USER', '');
  30. /**
  31. * Name of the database to use
  32. */
  33. defined('MYSQL_DATABASE') or define('MYSQL_DATABASE', '');
  34. =======
  35. const MYSQL_HOST = 'localhost';
  36. /**
  37. * Login name for MySQL
  38. */
  39. const MYSQL_USER = 'raul21';
  40. /**
  41. * Name of the database to use
  42. */
  43. const MYSQL_DATABASE = 'sitename';
  44. >>>>>>> Stashed changes
  45.  
  46. /**
  47. * Password for the MySQL user
  48. */
  49. $mysql_pass = 'raul21';
  50.  
  51. /**
  52. * Link that will be returned in order to create queries on other modules
  53. */
  54. $mysql_link = mysqli_connect(MYSQL_HOST, MYSQL_USER, $mysql_pass, MYSQL_DATABASE);
  55.  
  56. unset($mysql_pass);
  57.  
  58. if($mysql_link !== FALSE){
  59. $num_cleaned = clean_expired_sess($mysql_link);
  60.  
  61. if($num_cleaned === FALSE){
  62. writeLog($config['logger']['sess_cleanup'], '(' . mysqli_errno($mysql_link)
  63. . ') ' . mysqli_error($mysql_link) . PHP_EOL);
  64. }
  65. }
  66.  
  67. return $mysql_link;
  68. /* vim: set ts=4 sw=4 tw=80 sts=4 fdm=marker nowrap et :*/
Add Comment
Please, Sign In to add comment