<?php
$active_group = 'default';
$query_builder = TRUE;
$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'campus';
$db['default']['password'] = 'Mac@123';
$db['default']['database'] = 'campusnew';
$db['default']['dbdriver'] = 'mysqli';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = TRUE;
$db['otherdb']['hostname'] = "101.51.150.42";
$db['otherdb']['username'] = 'software';
$db['otherdb']['password'] = 'Lmsnew';
$db['otherdb']['database'] = 'lmsnew';
$db['otherdb']['dbdriver'] = "mysqli";
$db['otherdb']['dbprefix'] = "";
$db['otherdb']['pconnect'] = TRUE;
$db['otherdb']['db_debug'] = FALSE;
$db['otherdb']['cache_on'] = FALSE;
$db['otherdb']['cachedir'] = "";
$db['otherdb']['char_set'] = "utf8";
$db['otherdb']['dbcollat'] = "utf8_general_ci";
$db['otherdb']['swap_pre'] = "";
$db['otherdb']['autoinit'] = TRUE;
$db['otherdb']['stricton'] = TRUE;
模型函数
public function newusersignin()
{
$DB2 = $this->load->database('otherdb', TRUE);
$firstName=$this->input->post('firstName');
$lastName=$this->input->post('lastName');
$timezone=$this->input->post('timezone');
$fullname=$firstName.' '.$lastName;
$email=$this->input->post('email');
$phone=$this->input->post('phone');
$ip_address=$this->input->ip_address();
$institutional=$this->input->post('institutional');
$pass=$firstName.mt_rand(1,100);
$username=$email;
$password=$this->hash($pass);
}
在这个问题中,我只是创建了两个数据库连接,一个用于localhost,另一个用于IP托管在不同的服务器上。现在,当我要在我的IP服务器中插入表单数据时会发生什么,然后它会抛出一个错误,即
消息:mysqli::real_connect(): (HY000/2002): 连接被拒绝
我不知道为什么会这样?我怎么解决这个问题?请帮我。
慕田峪4524236
慕码人2483693
慕莱坞森