views:

143

answers:

3

Hello. I have three files: one called sql.php witch has a class db that I use to ease the get results operation from MySQL; one called session.class.php that has class session (extending class db) witch I use to make my basic operations as functions... like check_login function witch I use to check if user is logged in; and another one called main.class.php that I have from a login module posted on a forum. At first it used another file as MySQL wrapper called mysql.class.php that I didn't like and replaced it with my sql.php. Now, I get an error in my main.class.php file like this:

"Warning: Missing argument 2 for db::db(), called in C:\wamp\www\extlogin\inc\main.class.php on line 14 and defined in C:\wamp\www\extlogin\inc\sql.php on line 33

Warning: Missing argument 3 for db::db(), called in C:\wamp\www\extlogin\inc\main.class.php on line 14 and defined in C:\wamp\www\extlogin\inc\sql.php on line 33

Warning: Missing argument 4 for db::db(), called in C:\wamp\www\extlogin\inc\main.class.php on line 14 and defined in C:\wamp\www\extlogin\inc\sql.php on line 33"

My main.class.php file looks like this:

<?php
    require_once("sql.php");
    require_once("session.class.php");
    class main extends db {
        public function __construct() {
            header('Content-Type: text/html; charset=iso-8859-1');
            session_start();            
            if (class_exists('db')) {

            } else {
                die("Database class does not exist!");
            }
            if (class_exists('session')) {
                $this->session = new session($this);
            } else {
                die("Session class does not exist!");
            } 

        }
    }
?>

Where line 14 in my main.class.php file has this: $this->session = new session($this); and line 33 in my sql.php file has the function db for connection defined like this:

function db($dbuser, $dbpassword, $dbname, $dbhost)

Can anybody tell my how to fix this error ? I could give you more details if you need them.

Thanks.

A: 

On line 33 you are initializing the db class without satisfying its last three parameters. The error is pretty straightforward...

orlandu63
A: 

The error is in sql.php. Check that file, db:db() seems to need some parameters.

As best practice:

  • you should not display the errors in the generated html file
  • set error level to warning, or lower
  • monitor the log file for errors
Mercer Traieste
A: 

Are you sure you need to extend class 'db'?

Take a look at session.class.php in the constructor. It seems that it is trying to create an instance of a 'db' class, which requires some input parameters. You may need to pass some additional parameters to the session class or perhaps have a db instance initialized beforehand.

safoo