Service Unavailable


I am trying to add a compare list product to database as it adds into the session. for that I am writing an insert query in “controller/frontend/product_features.php

[quote]if ($mode == 'add_product') {

if (empty($_SESSION['comparison_list'])) {

$_SESSION['comparison_list'] = array();


$p_id = $_REQUEST['product_id'];

if (!in_array($p_id, $_SESSION['comparison_list'])) {

db_query(“INSERT INTO ?:user_session_products (user_id, timestamp, product_id, type) values ('”.$_SESSION['auth']['user_id'].“', '”.time().“', '”.$p_id.“', 'A')”);

array_unshift($_SESSION['comparison_list'], $p_id);

$added_products = array();

$added_products[$p_id]['product_id'] = $p_id;

$added_products[$p_id]['display_price'] = fn_get_product_price($p_id, 1, $_SESSION['auth']);

$added_products[$p_id]['amount'] = 1;

$added_products[$p_id]['main_pair'] = fn_get_cart_product_icon($p_id);

Registry::get('view')->assign('added_products', $added_products);[/quote]

this query runs well when user add very first product into comapre list but when user adds second product query fails.

What is wrong in this? Please suggests me.


What is the db error?

To see the error message, please open the config.local.php file and replace:

ini_set('display_errors', 0);


ini_set('display_errors', 1);
define('DEVELOPMENT', true);

what is the table definition? I know on one of my tables, the primary key field must be unique. you have user_id and product_id which could be the cause of the insert failure.

By definition, a primary key must always be unique. It can span multiple columns, but it must be unique.