Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/239.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Codeigniter用户会话错误_Php_Mysql_Codeigniter_Session_Login Control - Fatal编程技术网

Php Codeigniter用户会话错误

Php Codeigniter用户会话错误,php,mysql,codeigniter,session,login-control,Php,Mysql,Codeigniter,Session,Login Control,我在Codeigniter框架中面临一个新问题。她是我最讨厌的人 Array ( [id] => 2 [firstname] => Maruf [lastname] => Ifftekhar [slug] => [email] => support@russelhost.com [email_subscribe] => 1 [self] => [phone] => 01767820010 [company] => Rus

我在Codeigniter框架中面临一个新问题。她是我最讨厌的人

Array ( [id] => 2 [firstname] => Maruf [lastname] => Ifftekhar [slug] => [email] => support@russelhost.com [email_subscribe] => 1 [self] => [phone] => 01767820010 [company] => Russel Host [default_billing_address] => [default_shipping_address] => [ship_to_bill_address] => true [password] => 0689d59aa30bdca7207db3d449255650 [active] => 1 [group_id] => 1 [confirmed] => 0 [group_discount_formula] => - 0 [expire] => 1380390903 ) A PHP Error was encountered Severity: Notice Message: Trying to get property of non-object Filename: controllers/secure.php Line Number: 46 abida Sultana 排列 ( [id]=>2 [名字]=>Maruf [lastname]=>Ifftekhar [slug]=> [电子邮件]=>support@russelhost.com [电子邮件订阅]=>1 [自我]=> [电话]=>01767820010 [公司]=>Russel主机 [默认账单地址]=> [默认装运地址]=> [发货至账单地址]=>正确 [密码]=>0689d59aa30bdca7207db3d449255650 [活动]=>1 [组id]=>1 [已确认]=>0 [集团折扣公式]=>-0 [到期]=>1380390903 ) 遇到一个PHP错误 严重性:通知 消息:正在尝试获取非对象的属性 文件名:controllers/secure.php 电话号码:46 阿比达苏丹 这是控制器

`$`email = `$`this->input->post('email'); `$`password = `$`this->input->post('password'); `$`remember = `$`this->input->post('remember'); `$`redirect = `$`this->input->post('redirect'); `$`login = `$`this->Customer_model->login(`$`email, `$`password, `$`remember); echo '/pre>-----'; print_r(`$`login); echo 'abida Sultana'.`$`login->last_name; --------------------Line Number: 46 exit(); `$`email=`$`this->input->post('email'); `$`password=`$`this->input->post('password'); `$`memory=`$`this->input->post('memory'); `$`redirect=`$`this->input->post('redirect'); `$`login=`$`this->Customer\u model->login(`$`电子邮件,`$`密码,`$`记住); 回音'/pre>---'; 打印(`$`login); echo'abida Sultana.`$`登录->姓氏--------------------电话号码:46 退出(); 模型是

function login(`$`email, `$`password, `$`remember = false) { `$`this->db->select('*'); `$`this->db->where('email', `$`email); `$`this->db->where('active', 1); `$`this->db->where('password', md5(`$`password)); `$`this->db->limit(1); `$`result = `$`this->db->get('customers'); `$`customer = `$`result->row_array(); if (`$`customer) { // Retrieve customer addresses `$`this->db->where(array('customer_id' => `$`customer['id'], 'id' => `$`customer['default_billing_address'])); `$`address = `$`this->db->get('customers_address_bank')->row_array(); if (`$`address) { $fields = unserialize($address['field_data']); $customer['bill_address'] = $fields; $customer['bill_address']['id'] = $address['id']; // save the addres id for future reference } $this->db->where(array('customer_id' => $customer['id'], 'id' => $customer['default_shipping_address'])); $address = $this->db->get('customers_address_bank')->row_array(); if ($address) { $fields = unserialize($address['field_data']); $customer['ship_address'] = $fields; $customer['ship_address']['id'] = $address['id']; } else { $customer['ship_to_bill_address'] = 'true'; } // Set up any group discount if ($customer['group_id'] != 0) { $group = $this->get_group($customer['group_id']); if ($group) { // group might not exist if ($group->discount_type == "fixed") { $customer['group_discount_formula'] = "- " . $group->discount; } else { $percent = (100 - (float) $group->discount) / 100; $customer['group_discount_formula'] = '* (' . $percent . ')'; } } } if (!$remember) { $customer['expire'] = time() + $this->session_expire; } else { $customer['expire'] = false; } // put our customer in the cart $this->go_cart->save_customer($customer); return $customer; } else { return false; } } 函数登录(`$`电子邮件,`$`密码,`$`记住=false){ `$`this->db->select('*'); `$`this->db->where('email',`$`email); `$`this->db->where('active',1); `$`this->db->where('password',md5(`$`password)); `$`此->数据库->限制(1); `$`result=`$`this->db->get('customers'); `$`customer=`$`result->row_array(); 如果(`$`客户){ //检索客户地址 `$`this->db->where(数组('customer\u id'=>`$`customer['id'],'id'=>`$`customer['default\u billing\u address']); `$`address=`$`this->db->get('customers\u address\u bank')->row\u array(); 如果(`$`地址){ $fields=unserialize($address['field_data']); $customer['bill_address']=$fields; $customer['bill_address']['id']=$address['id'];//保存地址id以备将来参考 } $this->db->where(数组('customer\u id'=>$customer['id'],'id'=>$customer['default\u shipping\u address']); $address=$this->db->get('customers\u address\u bank')->row\u array(); 如果($地址){ $fields=unserialize($address['field_data']); $customer['ship_address']=$fields; $customer['ship_address']['id']=$address['id']; }否则{ $customer['ship_to_bill_address']='true'; } //设置任何团体折扣 如果($customer['group_id']!=0){ $group=$this->get_group($customer['group_id'); 如果($group){//组可能不存在 如果($group->折扣类型==“固定”){ $customer['group\u discount\u formula']=“-”$group->discount; }否则{ $percent=(100-(浮动)$group->折扣)/100; $customer['group_折扣公式']='*('.$percent.'); } } } 如果(!$记住){ $customer['expire']=time()+$this->session\u expire; }否则{ $customer['expire']=false; } //把我们的顾客放到购物车里 $this->go\u cart->save\u customer($customer); 返回$customer; }否则{ 返回false; } }
如果对
登录
变量执行
var\u转储
,您将看到它是一个数组,而不是一个对象,因此无法像处理对象一样处理它

 //You used this code because row_array return array not object
 `$`login["result"] = `$`this->Customer_model->login(`$`email, `$`password, `$`remember);
  echo  $login['result']["last_name"];
因此,请转到您的模型并修改以下内容:

$customer = $result->row_array();
将是:

$customer['result'] = $result->row_array();
然后在第46行中,将其用作:

$login['result']->last_name;
发生这种情况的原因:

因为正如您最初定义的那样,
$customer
是一个对象。稍后,您还通过使用
$customer['something']
分配模式,将其重新定义为一个数组。
所以你不能随心所欲,它要么是数组,要么是对象。

问题是什么?返回tics用于什么?遇到了一个PHP错误严重性:注意消息:尝试获取非对象文件名的属性:controllers/secure.PHP行号:46 abida SultanaSearch并删除这些返回标记以开始<代码>$电子邮件应为$email.echo“pre>----
”;打印(登录);echo'abida Sultana.$login['result']->姓氏;退出()$login=$this->Customer\u model->login($email,$password,$memory);回声'----
';打印(登录);echo'abida Sultana.$login['result']->姓氏;退出();您过去常常获取
消息:尝试获取非对象的属性
,这与错误不同。新错误现在显示
未定义属性:stdClass::$last\u name
。这意味着没有从数据库中提取姓氏。@易卜拉欣-只需确保从数据库中获取姓氏即可
 //You used this code because row_array return array not object
 `$`login["result"] = `$`this->Customer_model->login(`$`email, `$`password, `$`remember);
  echo  $login['result']["last_name"];