Object of class CI_DB_mysql_result could not be converted to string |
[eluser]vickel[/eluser]
Hallo everybody, I'm building a shopping cart and get the above error on a certain occasion: I have in a controller the function refresh() which contains: $this->db->select('*'); $this->db->where('sessionID', $guestSessionID); $data['cartNow'] = $this->db->get('ticket'); $this->load->view('cart_view', $data); in the view I use: <?php foreach($cartNow->result() as $row): //get variables from tables products corresponding to the ticket $this->db->select('*'); $this->db->from('products'); $this->db->join('ticket', 'products.prodID = ticket.prodID'); $this->db->where('ticket.prodID', $row->prodID); $query = $this->db->get(); $row = $query->row(); ?> ... ... <?php endforeach?> the view has a checkbox, when it is checked the item is deleted from the database, this WORKS FINE if I have 2 items and remove the first, but DOESN'T WORK if i have 2 items and remove the second. PS.: if I use after that error the above function (refresh) again, all is OK. In the database everything is OK thank you for any help on that
[eluser]vickel[/eluser]
Hallo everybody, I'm building a shopping cart and get the above error on a certain occasion: I have in a controller the function refresh() which contains: Code: $this->db->select('*'); in the view I use: Code: <?php foreach($cartNow->result() as $row): the view has a checkbox, when it is checked the item is deleted from the database, this WORKS FINE if I have 2 items and remove the first, but DOESN'T WORK if i have 2 items and remove the second. PS.: if I use after that error the above function (refresh) again, all is OK. In the database everything is OK all the time thank you for any help on that[/quote]
[eluser]Jilani Jidni[/eluser]
[quote author="vickel" date="1218390780"]Hallo everybody, I'm building a shopping cart and get the above error on a certain occasion: I have in a controller the function refresh() which contains: Code: $this->db->select('*'); in the view I use: Code: <?php foreach($cartNow->result() as $row): the view has a checkbox, when it is checked the item is deleted from the database, this WORKS FINE if I have 2 items and remove the first, but DOESN'T WORK if i have 2 items and remove the second. PS.: if I use after that error the above function (refresh) again, all is OK. In the database everything is OK all the time thank you for any help on that[/quote][/quote] Hi vickel Its not clear how you send the request to the server for delete. And one suggestion from myself please don't do any query from the view page. use model for to do database related job. controller will do all kind of business logic and view will just display the output. please read the manual for details.
[eluser]vickel[/eluser]
Thank you Jilani, for your reply, there is no problem with the delete operation at all, its just that the line Code: $data[’cartNow’] = $this->db->get(’ticket’); causes the error, but only if I delete the second record of two (or for example the third of 4) ????
[eluser]Jilani Jidni[/eluser]
[quote author="vickel" date="1218465367"]Thank you Jilani, for your reply, there is no problem with the delete operation at all, its just that the line Code: $data[’cartNow’] = $this->db->get(’ticket’); causes the error, but only if I delete the second record of two (or for example the third of 4) ????[/quote] Sorry its not clear for me. why you are facing this problem. can you send the whole code?
[eluser]vickel[/eluser]
Hi Jilani, thank you for your time, her comes the code Code: function refresh() $data['cartNow'] = $query; is the line which causes the error Code: //var_dump($data['cartNow']);
[eluser]Jilani Jidni[/eluser]
sorry vickel I am unable to answer your problem. I think I could not read your code properly.
[eluser]vickel[/eluser]
thanks for your time anyway, if you want to see what's happening goto www.ericeiraglass.com/shop, add 2 items to the shopping cart and remove the first, everything is fine. add another item and this time delete the second: here then comes the error ::: ::: just put the database stuff into a model, now it works thanks everybody |
Welcome Guest, Not a member yet? Register Sign In |