Welcome Guest, Not a member yet? Register   Sign In
Object of class CI_DB_mysql_result could not be converted to string
#6

[eluser]vickel[/eluser]
Hi Jilani, thank you for your time, her comes the code

Code:
function refresh()
    {

    
    //check if 'username' exists
    // it doesn't exist after cleaning cache and going back by bookmark
    // to http://www.ericeiraglass.com/shop/index.php/products/refresh
    
    $guestSessionID = $this->session->userdata('username');
    
    if ($guestSessionID!="")
        {
    
        $query = $this->db->get_where('ticket', array('sessionID' => $guestSessionID));
        $myRows = $query->num_rows();
        $myR=$myRows;
        
        if ($myRows!=0)
        {
            for ($i=1; $i<=$myRows; $i++)
                {    
                $data = $this->input->post('remove'.$i);     // remove1,2... is the checkbox value ('checked')
                
                if ($data=='checked')
                    {
                    $prodID=$this->input->post('myID'.$i);        // the value of product ID
    
                    
                    $this->db->delete('ticket', array('prodID' => $prodID));
                    $myR=$myR-1;
                    
                    }
                        
                
                else
                    {
                    $quant = $this->input->post('quantity'.$i);        // update the Textarea in each row
                    $prodID=$this->input->post('myID'.$i);            // the value of product ID
                    
                    $this->db->where('prodID', $prodID);
                    $this->db->update('ticket', array('quantity' => $quant));
                    }
                        
                }    //ends the for loop
                
            
            //output views
            //get the ticket data and send it to the cart_view
            
            
            if ($myR==0)
                {
                // no ticket exist
                $this->load->view('emptyCart');                        
                }
            else
                {    
                
                $ticketdata = array(
                                   'sessionID' => $guestSessionID ,
                                   'prodID' => $prodID ,
                                   'last_change' => time(), //date('yy-m-d'),
                                   'quantity' => 1);    
                
                //$data['cartNow'] = $this->db->get_where('ticket', 'sessionID' = $guestSessionID);
                //doesn't work !!!
                                    
                // data query to populate with shoppingcart items
                // from the current ticket
        

                $this->db->select('*');
                $this->db->where('sessionID', $guestSessionID);
                //$this->db->order_by("last_change", "desc");
            
            
                $query = $this->db->get('ticket');
                $row = $query->row_array();  
                
                //return $query->row_array();
                //echo "rowID= " . $row['prodID'];
                

                
                //build an array
                //var_dump($query);
                $data['cartNow'] = $query;

$data['cartNow'] = $query; is the line which causes the error
Code:
//var_dump($data['cartNow']);
                //$data['cartNow']=$query->result_array();
                
                

                
                $this->load->view('cart_view', $data);
                
                
                //get the product from ticket, which was latest changed
                //this is to get the $data array to build the left_products view
                
                $mySql="
                SELECT Max(ticket.last_change) AS mylastchange, productCat.catName, productCat.catID
                FROM (ticket
                INNER JOIN products ON ticket.prodID = products.prodID)
                INNER JOIN productCat ON products.prodCat = productCat.catID
                GROUP BY productCat.catName, ticket.sessionID, productCat.catID
                HAVING (((ticket.sessionID)='" . $guestSessionID . "'))";  
                
                $query = $this->db->query($mySql);    
                $row = $query->row_array();
                
                $prodID = $row['catID'];
                
                $data['catID'] = $this->db->get_where('productCat', array('catID' => $prodID));            
                $data['subcatID'] = $this->db->get_where('productSubCat', array('catID' => $prodID));
                
                $this->load->view('leftbar_products', $data);
    
                if ($this->session->userdata('logged_in') == TRUE)
                    {
                    $this->load->view('rightbar_loggedIn', $data);
                    }
                else
                    {
                    $data['usern'] = array('id' => 'usern', 'name' => 'usern');
                    $data['passw'] = array('id' => 'passw', 'name' => 'passw');                    
                    $this->load->view('rightbar_loggedOut', $data);
                    }

                $this->load->view('menu', $data);        

                }
            }
        else
        {
        // no ticket exist
        $this->load->view('emptyCart');    
        }
        }    
    else
        {
        // implement session destroy (must be last)
        
                $this->session->sess_destroy();
        
        //add userinfo to new session cookie
        $guestID = "guest" . mt_rand();
        $newdata = array(
           'username'  => $guestID,
           'logged_in' => FALSE);

        $this->session->set_userdata($newdata);    
        $this->load->view('emptyCart');
        }        

    }    //end of functiom refresh


Messages In This Thread
Object of class CI_DB_mysql_result could not be converted to string - by El Forum - 08-11-2008, 04:05 AM



Theme © iAndrew 2016 - Forum software by © MyBB