PHP脚本错误

时间:2011-04-02 23:41:33

标签: php mysql sql

我收到此错误:

Fatal error: Call to a member function query() on a non-object in C:\EasyPHP-5.3.6.0\www\Database Manager\install\registration.php on line 18

继承我的代码:

<?php
include("../sql_information.php");

class infos {

    private $sql_initialize;

    function login_details() {

        $sql_initialize = new MySQLDatabase();
        $sql_initialize;
        user_name='$register_user_name'";
        $queryresult = $this->sql_initialize->query($sql);


        if ($sql_initialize->fetchArray($queryresult)) {
            $errors[] = "Username already taken";
        }

        if ($register_password !== $confirm_password) {
            $errors[] = "Passwords mismatch";
        }

        if (!$errors) {
            //$register_password = mysql_real_escape_string($register_password);
            $sql = "INSERT INTO `data_manager`.`user_accounts` (`id`, `user_name`, `password`) VALUES (NULL, '$register_user_name', '$register_password')";
            mysql_query($sql);
            print "registered !";
            //header("Location: complete.php");
            exit;
        } else {
            foreach ($errors as $err) echo $err;
        }
    }
}
?>

3 个答案:

答案 0 :(得分:3)

login_details的第一行,您要设置本地变量$sql_initialize。您需要设置$this->sql_initialize

答案 1 :(得分:1)

$sql_initialize = new MySQLDatabase();

...

$queryresult = $this->sql_initialize->query($sql);

您可能尝试在$this->sql_initialize处创建对象,而不是$sql_initialize

答案 2 :(得分:0)

最有可能的是MySQL数据库由于错误而没有返回对象,可能是在MySQL数据库类中!!