[SOLVED] INSERT in MySQL problem... My code is not working?

My code is not working. But it DOES NOT return any errors… It’s weird. The pages loads fine and I checked all of the varibles by echoing them into the page for me to see and make sure they were good… but when I check to see if the data is in the database (mysql), nothing is there… Need help with this.

<?php if (isset($_POST['AddToCart'])) { $qty = "1"; foreach ($_POST["Component_ID"] as $type => $component) { // mysql_select_db($database_DM_database, $DM_database) or die(mysql_error()); mysql_query("INSERT INTO tblshoppingcart (Cookie_ID, Product_ID, Component_ID, qty) VALUES (" . GetCartId() . ", " . intval($ProductID) . ", " . intval($component) . ", " . intval($qty) . ")"); } //header("Location: cart.php"); } else { $ihateyou = "I HATE YOU"; } ?>

Anyone see anything thats maybe wrong… and could cause this.

FYI: GetCartId() just returns the session ID … which currently for me when echo is: f765354f720f0d73ac26194fe47fb016

Here is the error I got:

Unknown column ‘f765354f720f0d73ac26194fe47fb016’ in ‘field list’

I got it…

This is the code that works:

<?php if (isset($_POST['AddToCart'])) { $qty = "1"; foreach ($_POST["Component_ID"] as $type => $component) { $query = "INSERT INTO tblshoppingcart (`Cookie_ID`, `Product_ID`, `Component_ID`, `qty`) VALUES ('" . GetCartId() . "', " . intval($ProductID) . ", " . intval($component) . ", " . intval($qty) . ")"; mysql_query($query) or die("query='$query '<br>".mysql_error()); } //header("Location: cart.php"); } else { $ihateyou = "I HATE YOU"; } ?>

Sponsor our Newsletter | Privacy Policy | Terms of Service