dongsu4345 2012-03-04 20:05
浏览 34
已采纳

CodeIgniter:数据库错误'在哪里'

Update:

The below answer fixed my db error but I am not getting any success or error validation messages why?

View:

<h1><?php echo $companyName; echo nbs(1);?> - <?php echo $pageTitle; ?></h1>

    <p>Error: <?php echo validation_errors();?></p>

I am getting the following db error but I am unsure why because its two different tables:

Unknown column 'userActiveCode' in 'where clause'

SELECT `coreCompanyName`, `coreContactName`, `coreContactEmail` FROM (`core`) WHERE `userActiveCode` = '85domiigJZ'

Filename:/core_model.php

Line: 18

Controller:

function confirm(){

        $activateCode = $this->uri->segment(3);

        if($activateCode == '')
        {
            $this->form_validation->set_message('userConfirmError', 'Sorry you did not have a correct Activation Code.');
        }
            $userConfirmed = $this->users_model->confirm_user($activateCode);

            if($userConfirmed){
                $this->form_validation->set_message('userConfirmed', 'Thanks your account is now active you may login!');
            }else{
                $this->form_validation->set_message('userRecord', 'I am sorry we do not have any details with that Activation Code');
            }
            $data['companyName'] = $this->core_model->companyDetails()->coreCompanyName;
            $data['pageTitle'] = "User Confirm";
            $this->load->view('frontend/assets/header', $data);
            $this->load->view('frontend/user_confirm', $data);
            $this->load->view('frontend/assets/footer');
    }

Confirm Function:

function confirm_user($activateCode)
    {
     //Selects the userID where the given URI activateCode = ?

        $this->db->select('userID');
        $this->db->from('users');
        $this->db->where('userActiveCode', $activateCode);

        $result = $this->db->get();

        if($result->num_rows == 1)  // If the above result is = 1 then update the userActive row else it will fail
        {
            $this->db->set('userActive', 1);
            $this->db->where('userActiveCode', $activateCode);

            return TRUE;
        }else{
            return FALSE;
        }

Core Model:

function companyDetails()
    {
        static $details;

        if(!$details)
        {
            $this->db->select('coreCompanyName, coreContactName, coreContactEmail');
            $details = $this->db->get('core')->first_row();
        }
        return $details;
    }
  • 写回答

1条回答 默认 最新

  • douyan2821 2012-03-04 20:44
    关注

    You didn't finish the transaction to activate the user. Please try modifying the following code in UserModel::confirm_user:

    $this->db->set('userActive', 1);
    $this->db->where('userActiveCode', $activateCode);
    

    with

    $this->db->set('userActive', 1);
    $this->db->where('userActiveCode', $activateCode);
    $this->db->update('users');
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 逻辑谓词和消解原理的运用
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?