cs cart - PHP: unserialize() expects parameter 1 to be string -


if remove code works fine, need loop on products data (serialized) received. when use code breaks , don't know why.

$products = db_query("select cart ?:abandoned_cart user_id = ?s", $acid); //fn_print_die($products); $products = unserialize($products); $shippingcost = db_get_field("select shipping ?:abandoned_cart user_id = ?s", $acid); $tax = db_get_field("select tax ?:abandoned_cart user_id = ?s", $acid); $ordertotal = db_get_field("select order_total ?:abandoned_cart user_id = ?s", $acid); $email = db_get_field("select email ?:abandoned_cart user_id = ?s", $acid);  $sum=0; //echo $products; if (!empty($products)) {    foreach ($products $product) {     $text .='       <tr>         <td><a  href="http://'.$_server['server_name'].'?dispatch=products.view&product_id='.$product['product_id'].'"> <img title="" height="120" width="120" alt="" src="'.$product['main_pair']['detailed']['image_path'].'"></a></td>         <td><a href="#" style=" font-weight:bold; color:#333; font-size:13px; text-decoration:none;">'.$product['product'].'</a><a href="#">&nbsp;<i></i></a><div style=" font-weight:bold; color:#333; font-size:12px; margin-top:4px; text-decoration:none;"> code: <span>'.$product['product_code'].'<!--product_code_update_2512012004--></span> </div></td>         <td style=" text-align:center;"><span style=" font-weight:bold; color:#333; font-size:12px; margin-top:4px; text-decoration:none;">$</span><span style=" font-weight:bold; color:#333; font-size:12px; margin-top:4px; text-decoration:none;">'.$product['price'].'</span> </td>         <td><div style="display: inline-block;vertical-align: top;width: 56px;"><input type="text" disabled value="'.$product['amount'].'" size="3"  style="border:1px solid #c2c9d0; box-shadow:0 1px 3px rgba(0, 0, 0, 0.1) inset; border-radius:3px; float: left;height: 33px;text-align: center;width: 36px;"></div></td>         <td style="font-size:14px;  font-weight:bold; color:#333; text-align:center; font-size:13px; text-decoration:none;"><span>$</span><span stye=" color:#000;">'.$product['price']*$product['amount'].'</span> </td>       </tr>';     $sum =$sum+$product['price']*$product['amount'];   } } 

in log:

[mon feb 08 03:59:42 2016] [error] [client 90.199.142.58] php warning: unserialize() expects parameter 1 string, object given in /home/ambcom/public_html/staging/beanbags/app/addons/abandoned_cart_extended/controllers/backend/ac.php on line 24, referer: /admin.php?dispatch=cart.cart_list

it's literally unserialize breaks. i've tried removing part, , rest works. it's 4am now, , need working before 9am when need in office.

$products = db_query("select cart ?:abandoned_cart user_id = ?s", $acid); 

$products object first need fetch cart value in variable , pass unserialize method, assuming using mysqli can try this

if( $products->num_rows > 0 ){     $data = $products->fetch_assoc();      $products = unserialize($row['cart']);      $shippingcost = db_get_field("select shipping ?:abandoned_cart user_id = ?s", $acid);     $tax = db_get_field("select tax ?:abandoned_cart user_id = ?s", $acid);     $ordertotal = db_get_field("select order_total ?:abandoned_cart user_id = ?s", $acid);     $email = db_get_field("select email ?:abandoned_cart user_id = ?s", $acid);      $sum=0;     //echo $products;     if (!empty($products)) {        foreach ($products $product) {         $text .='           <tr>             <td><a  href="http://'.$_server['server_name'].'?dispatch=products.view&product_id='.$product['product_id'].'"> <img title="" height="120" width="120" alt="" src="'.$product['main_pair']['detailed']['image_path'].'"></a></td>             <td><a href="#" style=" font-weight:bold; color:#333; font-size:13px; text-decoration:none;">'.$product['product'].'</a><a href="#">&nbsp;<i></i></a><div style=" font-weight:bold; color:#333; font-size:12px; margin-top:4px; text-decoration:none;"> code: <span>'.$product['product_code'].'<!--product_code_update_2512012004--></span> </div></td>             <td style=" text-align:center;"><span style=" font-weight:bold; color:#333; font-size:12px; margin-top:4px; text-decoration:none;">$</span><span style=" font-weight:bold; color:#333; font-size:12px; margin-top:4px; text-decoration:none;">'.$product['price'].'</span> </td>             <td><div style="display: inline-block;vertical-align: top;width: 56px;"><input type="text" disabled value="'.$product['amount'].'" size="3"  style="border:1px solid #c2c9d0; box-shadow:0 1px 3px rgba(0, 0, 0, 0.1) inset; border-radius:3px; float: left;height: 33px;text-align: center;width: 36px;"></div></td>             <td style="font-size:14px;  font-weight:bold; color:#333; text-align:center; font-size:13px; text-decoration:none;"><span>$</span><span stye=" color:#000;">'.$product['price']*$product['amount'].'</span> </td>           </tr>';         $sum =$sum+$product['price']*$product['amount'];       }     }  } 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -