PHP extending to the MySQLI class

Solution:
If you look at the PHP reference for MySQLi (http://www.php.net/manual/en/class.mysqli.php), the original class constructor contains 6 parameters:
__construct ([ string $host = ini_get("mysqli.default_host") [, string $username = ini_get("mysqli.default_user") [, string $passwd = ini_get("mysqli.default_pw") [, string $dbname = "" [, int $port = ini_get("mysqli.default_port") [, string $socket = ini_get("mysqli.default_socket") ]]]]]] )
When extending MySQLi you have to define all of them, even if you are not using. Though, that's not what is causing the warning error.
In your case, you are calling$accounts = new Accounts();
without defining any arguments. Though,Accounts
class extentsBeatBeast_Database
. Therefore you need to pass all theBeatBeast_Database
constructor parameters ($db_host,$db_username,$db_password,$db_name
).
Answer
Solution:
Let's start with login.php, line 11
$accounts = new Accounts();
This calls the constructor of theAccounts
class - which has none defined. Since
Class Accounts extends BeatBeast_Database
PHP falls back to the constructor of theBeatBeast_Database
class:
public function __construct($db_host,$db_username,$db_password,$db_name)
which needs 4 parameters, but gets none - exactly what was in the error message. You will need to change line 11 oflogin.php
to
$accounts = new Accounts(DB_HOST, DB_USER, DB_PASSWD, DB_NAME);
or however the constants you define indb_constants.inc.php
are clled.
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: call to a member function store() on null
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.