Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/251.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/60.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP类错误_Php_Mysql_Class - Fatal编程技术网

PHP类错误

PHP类错误,php,mysql,class,Php,Mysql,Class,我有三个文件:一个叫做sql.php witch的文件有一个类db,我用它简化从MySQL获取结果的操作;其中一个叫做session.class.php,它有一个类session(扩展类db),我用它来将我的基本操作作为函数。。。像我用来检查用户是否登录的check_登录功能;还有另一个名为main.class.php的,是我在论坛上发布的登录模块中得到的。起初,它使用了另一个我不喜欢的文件作为MySQL包装,名为MySQL.class.php,并将其替换为我的sql.php。现在,我的main

我有三个文件:一个叫做sql.php witch的文件有一个类db,我用它简化从MySQL获取结果的操作;其中一个叫做session.class.php,它有一个类session(扩展类db),我用它来将我的基本操作作为函数。。。像我用来检查用户是否登录的check_登录功能;还有另一个名为main.class.php的,是我在论坛上发布的登录模块中得到的。起初,它使用了另一个我不喜欢的文件作为MySQL包装,名为MySQL.class.php,并将其替换为我的sql.php。现在,我的main.class.php文件中出现如下错误:

<?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!");
            } 

        }
    }
?>
function db($dbuser, $dbpassword, $dbname, $dbhost)
警告:在上的C:\wamp\www\extlogin\inc\main.class.php中调用的db::db()缺少参数2 第14行,并在第33行的C:\wamp\www\extlogin\inc\sql.php中定义

警告:在上的C:\wamp\www\extlogin\inc\main.class.php中调用的db::db()缺少参数3 第14行,并在第33行的C:\wamp\www\extlogin\inc\sql.php中定义

警告:在上的C:\wamp\www\extlogin\inc\main.class.php中调用的db::db()缺少参数4 第14行,并在第33行的C:\wamp\www\extlogin\inc\sql.php中定义”

我的main.class.php文件如下所示:

<?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!");
            } 

        }
    }
?>
function db($dbuser, $dbpassword, $dbname, $dbhost)
有人能告诉我如何修正这个错误吗?如果你需要的话,我可以给你更多的细节


谢谢。

在第33行,您正在初始化db类,但没有满足其最后三个参数。错误非常简单…

错误在sql.php中。检查该文件,db:db()似乎需要一些参数

作为最佳做法:

  • 您不应该在生成的html文件中显示错误
  • 将错误级别设置为警告或更低
  • 监视日志文件中的错误

您确定需要扩展“db”类吗

看看构造函数中的session.class.php。它似乎试图创建一个“db”类的实例,该类需要一些输入参数。您可能需要向会话类传递一些额外的参数,或者可能需要预先初始化一个db实例