1

How can i declare the DB Connection global so that every Class only use 1 config.php file ?

Atm i tried

global $db; define('DB_SERVER', 'localhost'); define('DB_USERNAME', 'root'); define('DB_PASSWORD', ''); define('DB_DATABASE', 'DATABASe'); $db = mysqli_connect(DB_SERVER,DB_USERNAME,DB_PASSWORD,DB_DATABASE); class login_class { function login($email,$pass) { 

And of cause then in my Class

$db = mysqli_connect(DB_SERVER,DB_USERNAME,DB_PASSWORD,DB_DATABASE); $query=mysqli_query($db, " SELECT * FROM users WHERE email='$email' AND password = '$pass' "); while($row=mysqli_fetch_array($query,MYSQLI_ASSOC)) { $userkey=$row['user_key']; $password=$row['password']; } 

But this isnt working ...

I have 10+ clases which i use there so i prefer to have only 1 config File but all i try isnt working...

2
  • have you included your config file? Commented Jul 16, 2015 at 9:57
  • my configs are at the moment at top of the Class File Commented Jul 16, 2015 at 10:03

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.