OOP PHP用户类(usercake)没有添加到数据库

Ada*_*dam 6 php mysql database oop usercake

我最近发现这个名为usercake(http://usercake.com/)的小用户类脚本,具有所有基本功能,似乎运行良好.

我的问题:第一个用户被添加到数据库中,但之后它无法正常工作.很明显,我只是有点错误,我没有搞清楚(我不太了解oop php).没有错误发生(我可以看到),电子邮件被发送出去.

我用同样的命运安装了多个地方.我想解决它,因为使用这个脚本可以节省大量重新启动轮时间.

这是我拥有它的URL:http://rawcomposition.com/birding/loggedin/register.php 这是在验证所有内容后调用的函数:

    public function userCakeAddUser()
{
    global $db,$emailActivation,$websiteUrl,$db_table_prefix;

    //Prevent this function being called if there were construction errors
    if($this->status)
    {
        //Construct a secure hash for the plain text password
        $secure_pass = generateHash($this->clean_password);

        //Construct a unique activation token
        $this->activation_token = generateActivationToken();

        //Do we need to send out an activation email?
        if($emailActivation)
        {
            //User must activate their account first
            $this->user_active = 0;

            $mail = new userCakeMail();

            //Build the activation message
            $activation_message = lang("ACTIVATION_MESSAGE",array($websiteUrl,$this->activation_token));

            //Define more if you want to build larger structures
            $hooks = array(
                "searchStrs" => array("#ACTIVATION-MESSAGE","#ACTIVATION-KEY","#USERNAME#"),
                "subjectStrs" => array($activation_message,$this->activation_token,$this->unclean_username)
            );

            /* Build the template - Optional, you can just use the sendMail function 
            Instead to pass a message. */
            if(!$mail->newTemplateMsg("new-registration.txt",$hooks))
            {
                $this->mail_failure = true;
            }
            else
            {
                //Send the mail. Specify users email here and subject. 
                //SendMail can have a third parementer for message if you do not wish to build a template.

                if(!$mail->sendMail($this->clean_email,"New User"))
                {
                    $this->mail_failure = true;
                }
            }
        }
        else
        {
            //Instant account activation
            $this->user_active = 1;
        }   


        if(!$this->mail_failure)
        {
                //Insert the user into the database providing no errors have been found.
                $sql = "INSERT INTO `".$db_table_prefix."Users` (
                        `Username`,
                        `Username_Clean`,
                        `Password`,
                        `Email`,
                        `ActivationToken`,
                        `LastActivationRequest`,
                        `LostPasswordRequest`, 
                        `Active`,
                        `Group_ID`,
                        `SignUpDate`,
                        `LastSignIn`
                        )
                        VALUES (
                        '".$db->sql_escape($this->unclean_username)."',
                        '".$db->sql_escape($this->clean_username)."',
                        '".$secure_pass."',
                        '".$db->sql_escape($this->clean_email)."',
                        '".$this->activation_token."',
                        '".time()."',
                        '0',
                        '".$this->user_active."',
                        '1',
                        '".time()."',
                        '0'
                        )";

            return $db->sql_query($sql);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

这是表结构:

CREATE TABLE IF NOT EXISTS `userCake_Users` (
  `User_ID` int(11) NOT NULL AUTO_INCREMENT,
  `Username` varchar(150) NOT NULL,
  `Name` varchar(100) NOT NULL,
  `Username_Clean` varchar(150) NOT NULL,
  `Password` varchar(225) NOT NULL,
  `Email` varchar(150) NOT NULL,
  `ActivationToken` varchar(225) NOT NULL,
  `LastActivationRequest` int(11) NOT NULL,
  `LostPasswordRequest` int(1) NOT NULL DEFAULT '0',
  `Active` int(1) NOT NULL,
  `Group_ID` int(11) NOT NULL,
  `SignUpDate` int(11) NOT NULL,
  `LastSignIn` int(11) NOT NULL,
  PRIMARY KEY (`User_ID`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;
Run Code Online (Sandbox Code Playgroud)

San*_*nne 0

您将Name指定为NOT NULL,并且在代码的Insert语句中没有发送Name值,因此mysql将抛出异常,说Name不能为空,请检查一次。