This really is my very first time here so i think you'll might help me. This really is my problem:

I am busy having a log-in script in oop.

I've the next classes ready:

  • database class
    case an connection/disconnection class

  • query class stretches the database class
    there's only one function which only requires a query string and obtain it with the database and finally returns an assortment using the data.

  • login class
    these kinds can get user login information and will get user informatie in the database.

this is actually the folder structure:

/cgi-bin -> holds the database and query class
/libraries -> holds the login class

Then you will find 2 files left and they're the index.php and also the global.php.

During my index I've this:



which is within my global.php:


$login = new Login();

this really is my login class

class Login extends Query{

  public function Login(){


  public function userCheck($userCredentials){
  $result = $this->qString('SELECT * FROM users');
  return $result;



and my query class

class Query extends Database{
  function qString($qString){

    //Start connection with database

    $result = $this->db->query($qString);
    // fetch associative array
    while ($row = mysqli_fetch_assoc($result)) {
      $data[] = $row;

    // free result set 

    //Close connection with database

    //Check mysqli connection
    //print_r(explode('  ', mysqli_stat($this->db)));

    return $data; 


and also the database class:

class Database {

  //Private variables for database connection.
  private $server;
  private $usern;
  private $userp;
  private $database;

  //The database object.
  protected $db;

  function Database(){

    $dbCredentials = explode(',',file_get_contents('cgi-bin/dbcredentials.txt'));

    $this->server = $dbCredentials[0];
    $this->usern  = $dbCredentials[1];
    $this->userp  = $dbCredentials[2];
    $this->db     = $dbCredentials[3];


  protected function conncect(){            
    $this->db = mysqli_connect($this->server, $this->usern, $this->userp, $this->db);

  protected function disconnect(){


now after i run this it states this:

Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\Login\cgi-bin\query.php on line 11

Warning: mysqli_free_result() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\Login\cgi-bin\query.php on line 16

Notice: Undefined variable: data in C:\xampp\htdocs\Login\cgi-bin\query.php on line 25

Why shall we be held getting this error?

Edit 12-10-2011:

I've discovered exactly what the error was.

simply to share it along with you: There error could be that the construct in the database class never was run.

Due to that, the bond particulars like account information were never set towards the private variables and knowning that it might never connect.

Which means that the qeury never could run in the login class.

Therefore it was really quite simple ultimately.