1) OK, I create the table use the following sql.
It is the same as the sql from zen cart or os-commerce.
DROP TABLE IF EXISTS products_to_categories;
CREATE TABLE products_to_categories (
products_id int(11) NOT NULL default '0',
categories_id int(11) NOT NULL default '0',
PRIMARY KEY (products_id,categories_id),
KEY idx_cat_prod_id (categories_id, products_id)
) TYPE=MyISAM;
2) And then assign $categories_id=2, and the $products_id=1 and run insert sql once. And assign $categories_id=2, and the $products_id=3, run the insert sql twice.
$sql_add_products_to_categories="INSERT INTO products_to_categories (categories_id, products_id) VALUES($categories_id, $products_id)";
$add_categories_products=mysql_query($sql_add_products_to_categories);
echo mysql_error();
3) The second time, I run the sql, I saw this message from echo mysql_error(); But the valuye '2-3' is inserted anyway.
Duplicate entry '2-3' for key 1