0

I don't understand why this line:

$this->db = mysqli($db['host'],$db['user'],$db['pass'],$db['name']);

Give me that error:

[05-Jul-2017 11:55:26 Europe/Berlin] PHP Fatal error: Uncaught Error: Cannot use object of type mysqli as array in /var/www/***/public_html/core/classes.php:7

Stack trace: #0 /var/www/***/public_html/core/classes.php(19): Database->connectDatabase()

1 /var/www/***/public_html/index.php(5): Core->__construct()

2 {main} thrown in /var/www/***/public_html/core/classes.php on line 7

I'm running Ubuntu Apache PHP7, phpinfo() does mention the mysqli ext.

1 Answer 1

0

Did you tried with keyword new before mysqli

$this->db = new mysqli($db['host'],$db['user'],$db['pass'],$db['name']);

Also check, is any of given parameters to mysqli function is array (it may cause the error). $db['host'],$db['pass'],$db['user'],$db['name'] should be strings

Sign up to request clarification or add additional context in comments.

3 Comments

Could you print_r($db) and post the output here, and remove the informations that you don't want to show here.
I've printed $db then realized my config file stored credential in $_db['host'] = "127.0.0.1" ... and the mysqli() was $db, changed it now it works.
Nice to know it! Best regards!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.