Welcome Guest, Not a member yet? Register   Sign In
Codeigniter Cart Insert Error..
#1

[eluser]ginteno[/eluser]
Hi can somebody tell me what's wrong with my cart insert code..
adding item to cart works perfect using localhost xampp but when i uploaded it online on my hosting.
the adding item cart part is showing errors..

Here is the Code

Code:
public function insert_cart(){
  
  $data = array(
       'id'      => 11,
       'qty'     => 1,
       'price'   => 500,
       'name'    =>' new_product',
       'options' => 888
  );
    
  print_r($data);
    
  $this->cart->insert($data);

}


ERROR MESSAGE

A PHP Error was encountered

Severity: Warning

Message: implode() [function.implode]: Invalid arguments passed

Filename: libraries/Cart.php

Line Number: 220

A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /home2/wusignco/public_html/nunez/system/core/Exceptions.php:185)

Filename: libraries/Session.php

Line Number: 675

A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /home2/wusignco/public_html/nunez/system/core/Exceptions.php:185)

Filename: helpers/url_helper.php

Line Number: 542



ERROR LOG FILE
[08-Apr-2014 17:26:50] PHP Parse error: syntax error, unexpected T_DOUBLE_ARROW in /home2/wusignco/public_html/nunez/application/controllers/cart.php on line 41
[08-Apr-2014 17:26:52] PHP Parse error: syntax error, unexpected T_DOUBLE_ARROW in /home2/wusignco/public_html/nunez/application/controllers/cart.php on line 41
[08-Apr-2014 18:07:44] PHP Warning: Unexpected character in input: ''' (ASCII=39) state=1 in /home2/wusignco/public_html/nunez/application/controllers/cart.php on line 122
[08-Apr-2014 18:07:44] PHP Parse error: syntax error, unexpected $end in /home2/wusignco/public_html/nunez/application/controllers/cart.php on line 122
[08-Apr-2014 18:09:01] PHP Parse error: syntax error, unexpected $end in /home2/wusignco/public_html/nunez/application/controllers/cart.php on line 65
[08-Apr-2014 18:09:23] PHP Parse error: syntax error, unexpected $end in /home2/wusignco/public_html/nunez/application/controllers/cart.php on line 171
[08-Apr-2014 18:11:36] PHP Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in /home2/wusignco/public_html/nunez/application/controllers/cart.php on line 40
[08-Apr-2014 18:11:38] PHP Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in /home2/wusignco/public_html/nunez/application/controllers/cart.php on line 40


Any help would be appreciated.. Thanks..
#2

[eluser]InsiteFX[/eluser]
And what is the code that's on line 40 in cart.php?
#3

[eluser]ginteno[/eluser]
34 public function insert_cart(){
35
36 $data = array(
37 'id' => 11,
38 'qty' => 1,
39 'price' => 500,
40 'name' => 'new_product',
41 'options' => 888
42 );
43
44 print_r($data);
45
46 $this->cart->insert($data);
47
48 }

As i debug it the name or options part causes error... i tried different string and integer to check the error but still no luck..
#4

[eluser]Tpojka[/eluser]
Probably irrelevant, but why is one blank space infront 'new_product'?
#5

[eluser]ginteno[/eluser]
i tried with or without underscore in the name but still same error.. it's 100% percent working on localhost.. i don't know why it's having error on my hosting.. do i have to set some config setting or what??
#6

[eluser]InsiteFX[/eluser]
Try putting a comma after the 888
#7

[eluser]ginteno[/eluser]
I already did that.. still no luck..
#8

[eluser]Tim Brownlaw[/eluser]
The options needs to be an array...

As stated in the users Guide...
$data = array(
'id' => 'sku_123ABC',
'qty' => 1,
'price' => 39.95,
'name' => 'T-Shirt',
'options' => array('Size' => 'L', 'Color' => 'Red')
);

Line 220 in cart.php is trying to perform an implode on a number... In your case 888 and that is why it is erroring...

So change your options to an array and see what happens.

The ID might also have to be a string and not an integer - it specifies it can be alpha-numeric which suggests it needs to have quotes to make it a string and not an integer.

See how that flies for you!

Cheers
Tim




Theme © iAndrew 2016 - Forum software by © MyBB