Q:

I am trying to create a table with only two foreign key

I have searched a lot but I could get only the concept that this is used for many to many linking. Or separate syntax for foreign key and primary key. But could not correct syntax as a whole.
CREATE TABLE cart
(
Customer varchar(40) FOREIGN KEY REFERENCES users(UserName),
Product varchar(40)  FOREIGN KEY REFERENCES products(PID),
CONSTRAINT combination PRIMARY KEY (Customer,Product)
);

I am getting the error
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'FOREIGN KEY REFERENCES users(UserName), Product varchar(40) FOREIGN KEY RE' at line 3

A:

Foreign key definitions go after all of the column definitions, they aren't defined inside the column definition. In your case, it would rather be:
CREATE TABLE cart
(
    Customer varchar(40),
    Product varchar(40),
    FOREIGN KEY (Customer) REFERENCES users(UserName),
    FOREIGN KEY (Product) REFERENCES products(PID),
    PRIMARY KEY (Customer,Product)
);

