我是codeigniter的新手,我只是想问一下如何摆脱这件事
A PHP Error was encountered
Severity: Notice
Message: Only variables should be passed by reference
Filename: database/DB_active_rec.php
Line Number: 225
我不知道为什么,这突然出来了,但我的页面做得很好,但这是我的页面顶部,如何摆脱这个东西,这就是我所拥有的:
Pages_Controller:
public function clients_ordered_products($id){
if(isset($_SESSION["id"])){
if($_SESSION["Usertype"]==1){
$this->load->view('admin/header');
$this->load->view('title/title_admin');
$this->load->view('admin/navigation');
$this->data["posts"] = $this->Generate_Model->getProductsClientsOrdered($id);
$this->load->view('admin/clients_ordered_products',$this->data);
$this->load->view('admin/footer');
}
else if($_SESSION["Usertype"]==0){
redirect('Pages_Controller/Ooops_Client');
}
}
else{
redirect($url);
}
}
和
Generate_Model:
public function getProductsClientsOrdered($id){
$this->db->select('*');
$this->db->select_sum('tbl_product_selected.Quantity');
$this->db->from('tbl_product_selected');
$this->db->join('tbl_product','tbl_product.Product_ID = tbl_product_selected.Product_ID');
$this->db->where('Account_ID',$id);
$this->db->where('Purchase_time',NULL);
$this->db->where('Active',1);
$this->db->group_by('tbl_product_selected.Product_ID');
$query = $this->db->get();
return $query->result();
}
和
<div id="page-wrapper">
<div class="cart">
<div class="container">
<div class="col-md-9 cart-items">
<!-- /.panel-heading -->
<div class="panel-body">
<table id="cart" class="table table-hover table-responsive">
<thead>
<tr>
<th>Product Name</th>
<th>Price</th>
<th>Quantity</th>
<th class="text-center">Subtotal</th>
<th>Action</th>
</tr>
</thead>
<?php $total = 0; ?>
<?php foreach($posts as $post){ ?>
<form action="<?php echo base_url(); ?>index.php/Transaction_Controller/removeItem/<?php echo $post->Product_selected_id; ?>" method="post">
<tbody>
<tr>
<td data-th="Product">
<div class="row">
<div class="col-sm-2 hidden-xs"> <img style="height:100px;"src="<?php echo $post->Directory?>"></div>
<div class="col-sm-10">
<h4 class="nomargin"></h4>
</div>
</div>
</td>
<td data-th="Price"><?php echo $post->Price;?></td>
<td data-th="Price" style="text-align:left"><input type="number" value="<?php echo $post->Quantity; ?>" class="form-control" style="width:60px"/></td>
<td data-th="Price" style="text-align:center"><?php echo $subtotal = $post->Price * $post->Quantity; ?></td>
<td class="actions" data-th="">
<a href="#" class="btn btn-primary btn-sm">UPDATE</a>
<button class="btn btn-danger btn-sm">DELETE<i class="fa fa-trash-o"></i></button>
</td>
</tr>
<?php $total += $subtotal; ?>
</tbody>
<tfoot>
<tr class="visible-xs">
<td class="text-center"><strong>
</strong></td>
</tr>
<tr>
<td></td>
<td colspan="2" class="hidden-xs"></td>
<td></td>
<td></td>
</tr>
</tfoot>
</form>
<?php } ?>
</table>
<center><form action="<?php echo base_url(); ?>index.php/Transaction_Controller/Products_Ordered/" method="post">
<input type="hidden" value="<?=$total?>" name="total"/>
<input type="hidden" value="<?php echo $post->Account_ID; ?>" name="id"/>
<button type="submit" class="btn btn-success btn-block">PAY NOW! <i class="fa fa-angle-right"></i></button>
</form><br/><br/>
</div>
</div>
</div>
</div>
为什么会这样?
答案 0 :(得分:1)
在使用CodeIgniter 2的一个项目上从PHP 5.6升级到PHP 7.1后,我遇到了同样的错误。 我这样解决了:
// line 224 of file /system/database/DB_active_rec.php
$explode = explode('.', $item);
return end($explode);
而不是
return end(explode('.', $item));
答案 1 :(得分:0)
此通知由E_STRICT错误报告触发,因为CodeIgniter 2中的此代码:
// DB_active_rec.php line 225
end(explode('.', $item));
CodeIgniter 2不再开发,您应该更新到CodeIgniter 3。