Tjena!
Håller på med en liten grej och får inte till det. Bifogar strukturen för de TABLEs jag försöker mata in data i samt php koden jag har idag.
Det är nått med de här btree och att dom ska använda samma ID som jag inte riktigt greppar.. Det enda jag igentligen behöver hjälp med är själva php koden för att föra in datan till "products_description"
table: products
PHP-kod:
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for products
-- ----------------------------
DROP TABLE IF EXISTS `products`;
CREATE TABLE `products` (
`products_id` int(11) NOT NULL AUTO_INCREMENT,
`products_quantity` int(4) NOT NULL DEFAULT 0,
`products_model` varchar(20) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL COMMENT 'Artikelnummer',
`products_replacement` varchar(20) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`products_image` varchar(64) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`products_price` decimal(15, 4) NOT NULL DEFAULT 0.0000,
`products_date_added` datetime(0) NOT NULL,
`products_last_modified` datetime(0) NULL DEFAULT NULL,
`products_date_available` datetime(0) NULL DEFAULT NULL,
`products_weight` decimal(5, 2) NOT NULL DEFAULT 0.00,
`products_status` tinyint(1) NOT NULL DEFAULT 0,
`products_stock` tinyint(1) NOT NULL DEFAULT 1,
`products_tax_class_id` int(11) NOT NULL DEFAULT 0,
`manufacturers_id` int(11) NULL DEFAULT NULL,
`products_ordered` int(11) NOT NULL DEFAULT 0,
PRIMARY KEY (`products_id`) USING BTREE,
UNIQUE INDEX `products_model`(`products_model`) USING BTREE,
INDEX `idx_products_date_added`(`products_date_added`) USING BTREE
) ENGINE = MyISAM CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Dynamic;
SET FOREIGN_KEY_CHECKS = 1;
table: products_description
PHP-kod:
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for products_description
-- ----------------------------
DROP TABLE IF EXISTS `products_description`;
CREATE TABLE `products_description` (
`products_id` int(11) NOT NULL AUTO_INCREMENT,
`language_id` int(11) NOT NULL DEFAULT 4,
`products_name` varchar(74) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL,
`products_description` text CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL,
`products_url` varchar(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`products_viewed` int(5) NULL DEFAULT 0,
PRIMARY KEY (`products_id`, `language_id`) USING BTREE,
INDEX `products_name`(`products_name`) USING BTREE
) ENGINE = MyISAM CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Dynamic;
SET FOREIGN_KEY_CHECKS = 1;
php koden.
PHP-kod:
$query = "INSERT INTO products (products_model, products_price, manufactures_id, products_quantity, products_image, products_date_added, products_last_modified, products_date_available, products_weight, products_status, products_stock, products_tax_class_id, products_ordered)
VALUES('$products_model', '$products_price', '$manufactures_id', '$products_quantity', '$products_image', '$mysql_date_now', '$mysql_date_now', '$mysql_date_now', '$products_weight', '$products_status', '$products_stock', '$products_tax_class_id', '$products_ordered')";
mysqli_query($db, $query);
$query2 = "INSERT INTO products_description (language_id, products_name, products_description, products_url, products_viewed)
VALUES('$pd_language_id', '$pd_products_name', '$pd_products_description', '$pd_products_url', '$pd_viewed')";
mysql_query($db, $query2);
}
Den felar på "mysql_query($db, $query2)".. jag förstår att jag gör nått som är fel..
antar hatt det har något att göra med "BTREE" ?
Alla fält och php variablar är rätta.