Advertisement
Guest User

Untitled

a guest
Dec 7th, 2016
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.06 KB | None | 0 0
  1. //basepath needs to be defined in order to include config file (there is a check for this!)
  2. define("BASEPATH", dirname(dirname(__FILE__)));
  3.  
  4. //push all config details (config.details returns them as array) into this array
  5. $config = require_once("application/config/config.php");
  6.  
  7.  
  8.  
  9. // DB CONNECTION DETAILS FOR LS
  10. $username = $config['components']['db']['username'];
  11. $password = $config['components']['db']['password'];
  12. $ls_dbprefix = $config['components']['db']['tablePrefix'];
  13. //the DB connection string looks like this:
  14. //'mysql:host=localhost;port=3306;dbname=etcvps88_devm;'
  15. //so we need to check for the last "=", add 1 and get the string without the ending ";" character:
  16. $database = substr($config['components']['db']['connectionString'],strrpos($config['components']['db']['connectionString'],"=")+1,-1);
  17.  
  18. //connect to Limesurvey DB
  19. $ls_connect = mysqli_connect("localhost",$username,$password,$database) or die( "Unable connect to Limesurvey database '$database'");
  20.  
  21. //set charset to deal with special characters
  22. mysqli_set_charset($ls_connect,'utf8');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement