Welcome Guest, Not a member yet? Register   Sign In
Why crash my code?
#1

(This post was last modified: 03-01-2020, 01:18 AM by omid_student.)

Hi
My codes is very simple
But when i run it,cpu usage get over 96%

PHP Code:
    function carts() {
    
$user_id $this->_check_login();

    
$this->db->select('*');
    
$carts $this->db->where('user_id',$user_id)->get('cart')->result_array();

    for (
$i $i count($carts) ; $i++) {
    
$pro_info   =   @$this->db->select('price,title')->where('pid',$carts['product_id'])->get('product')->row();
    
$carts[$i]['price'] =   $pro_info->price;
    
$carts[$i]['title'] =   $pro_info->title;
    }

    
$header['category'] =   $this->get_category();
    
$data['cat_id']     =   '';

    
$title  =   'carts';

    
$data['list'] = $carts;

    if (
$user_id != '') {
    
$info  = @$this->db->where('pid',$user_id)->get('user')->row();
    
$data['post']           =   $info->post_price;
    }

    
$data['title']          =   $title;
    
$data['tax']            =   0;

    
$this->load->view('site/master/header',$header);
    
$this->load->view('site/carts',$data);
    
$this->load->view('site/master/footer');

}

   function 
_check_login() {

        
$user_id    =   $this->session->userdata('user_id');

        if (!
preg_match('/^\d+$/',$user_id)) {
            
$this->session->set_flashdata('message','login to app<br>'.'<a class="btn btn-success" href="login">login</a>');
            
redirect('https://beautyfly.com/');
        }

        return 
$user_id;

    } 
Reply


Messages In This Thread
Why crash my code? - by omid_student - 03-01-2020, 01:15 AM
RE: Why crash my code? - by jreklund - 03-01-2020, 03:00 AM
RE: Why crash my code? - by omid_student - 03-01-2020, 03:27 AM
RE: Why crash my code? - by zahhar - 03-02-2020, 01:42 AM
RE: Why crash my code? - by omid_student - 03-02-2020, 09:45 AM
RE: Why crash my code? - by tweenietomatoes - 03-02-2020, 12:43 PM
RE: Why crash my code? - by InsiteFX - 03-02-2020, 02:02 PM
RE: Why crash my code? - by omid_student - 03-02-2020, 02:57 PM
RE: Why crash my code? - by nonebeliever - 03-03-2020, 03:26 AM
RE: Why crash my code? - by InsiteFX - 03-03-2020, 04:26 AM
RE: Why crash my code? - by omid_student - 03-03-2020, 05:50 AM
RE: Why crash my code? - by zahhar - 03-04-2020, 04:35 AM
RE: Why crash my code? - by omid_student - 03-04-2020, 05:27 AM



Theme © iAndrew 2016 - Forum software by © MyBB