Php CodeIgniter:数据库错误';其中';
更新:Php CodeIgniter:数据库错误';其中';,php,codeigniter,model,controller,Php,Codeigniter,Model,Controller,更新: <h1><?php echo $companyName; echo nbs(1);?> - <?php echo $pageTitle; ?></h1> <p>Error: <?php echo validation_errors();?></p> function confirm(){ $activateCode = $this->uri->segment(3)
<h1><?php echo $companyName; echo nbs(1);?> - <?php echo $pageTitle; ?></h1>
<p>Error: <?php echo validation_errors();?></p>
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');
}
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;
}
function companyDetails()
{
static $details;
if(!$details)
{
$this->db->select('coreCompanyName, coreContactName, coreContactEmail');
$details = $this->db->get('core')->first_row();
}
return $details;
}
下面的答案修复了我的db错误,但我没有收到任何成功或错误验证消息。为什么
查看:
<h1><?php echo $companyName; echo nbs(1);?> - <?php echo $pageTitle; ?></h1>
<p>Error: <?php echo validation_errors();?></p>
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');
}
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;
}
function companyDetails()
{
static $details;
if(!$details)
{
$this->db->select('coreCompanyName, coreContactName, coreContactEmail');
$details = $this->db->get('core')->first_row();
}
return $details;
}
控制器:
<h1><?php echo $companyName; echo nbs(1);?> - <?php echo $pageTitle; ?></h1>
<p>Error: <?php echo validation_errors();?></p>
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');
}
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;
}
function companyDetails()
{
static $details;
if(!$details)
{
$this->db->select('coreCompanyName, coreContactName, coreContactEmail');
$details = $this->db->get('core')->first_row();
}
return $details;
}
确认功能:
<h1><?php echo $companyName; echo nbs(1);?> - <?php echo $pageTitle; ?></h1>
<p>Error: <?php echo validation_errors();?></p>
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');
}
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;
}
function companyDetails()
{
static $details;
if(!$details)
{
$this->db->select('coreCompanyName, coreContactName, coreContactEmail');
$details = $this->db->get('core')->first_row();
}
return $details;
}
核心型号:
<h1><?php echo $companyName; echo nbs(1);?> - <?php echo $pageTitle; ?></h1>
<p>Error: <?php echo validation_errors();?></p>
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');
}
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;
}
function companyDetails()
{
static $details;
if(!$details)
{
$this->db->select('coreCompanyName, coreContactName, coreContactEmail');
$details = $this->db->get('core')->first_row();
}
return $details;
}
您没有完成事务以激活用户。请尝试在UserModel::confirm\u user中修改以下代码:
$this->db->set('userActive', 1);
$this->db->where('userActiveCode', $activateCode);
与
我不相信你在这里发布的代码会生成那个查询。你可以发布UserModel::confirm\u user的代码吗?你应该发布另一个问题。