public static function inserCartItemsLoggedIn($user_id, $cart) { try { $dbh = new PDO(DB_DSN, DB_LOGIN, DB_PASSWORD); } catch (PDOException $e) { print "Error!: " . $e->getMessage() . "<br/>"; die; } $item_id = substr($cart, 0, strlen($cart) - 1); $cat = substr($cart, -1); $cost = ADAO::getCostofItemByCat($item_id, $cat); //echo "Cost is ". $cost; $stmt = $dbh->prepare("INSERT into t_users_cart values(NULL," . $user_id . "," . $item_id . "," . $cat . "," . $cost . ")"); $stmt->execute(); $dbh = null; }