I'm trying to insert this information into my database, I have practically the same code setup for SELECT queries and they work. Any INSERT queries I try will not work.
This function returns true, and I've echoed the query this function creates and have used PHPMyAdmin to run the SQL query where it'll show in the database but when doing it through this php code the INSERT never shows up in the database.
EDIT : I noticed that one of my columns (orderID
) that is set to auto increment IS increasing every time I run this function but for whatever reason the query is not actually getting placed into the table.
This Image shows orderID
of 29 is missing, I got those table results by doing 2 PHPMyAdmin INSERT queries, then one with the function and one more with PHPMyAdmin. Is there any way my function could be deleting the insert?
function add_to_cart($user_id, $product_id, $quantity) {
global $mysqli;
if($result = $mysqli->query("INSERT INTO orders (userID, productID, quantity, orderDate) VALUES ('$user_id', '$product_id', '$quantity', NOW())")){
return $result;
}
return false;
}
The user connecting to the database has full privileges to the database so that shouldn't be the issue