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

[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('*');
$this->db->where('sessionID', $guestSessionID);
$data['cartNow'] = $this->db->get('ticket');
$this->load->view('cart_view', $data);

in the view I use:

Code:
<?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 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.


Messages In This Thread
Object of class CI_DB_mysql_result could not be converted to string - by El Forum - 08-10-2008, 11:48 PM



Theme © iAndrew 2016 - Forum software by © MyBB