Hey there guys,
I'm really struggling to find the error in my code, and could use some help.
I have a function in a PHP file that reads like this:
function getCartContent()
{
$cartContent = array();
$sid = session_id();
$sql = "SELECT ct_id, ct.pd_id, pd_size, ct_qty, pd_name, pd_price, pd_thumbnail, pd.cat_id
FROM tbl_cart ct, tbl_product pd, tbl_category cat
WHERE ct_session_id = '$sid' AND ct.pd_id = pd.pd_id AND cat.cat_id = pd.cat_id";
$result = dbQuery($sql);
while ($row = dbFetchAssoc($result)) {
$cartContent[] = $row;
}
return $cartContent;
}
I then have a call to this function in a separate file:
for ($i = 0; $i < $numItem; $i++) {
$sql = "INSERT INTO tbl_order_item(od_id, pd_id, od_qty, product_size)
VALUES ($orderId, {$cartContent[$i]['pd_id']}, {$cartContent[$i]['ct_qty']}, {$cartContent[$i]['pd_size']})";
$result = dbQuery($sql);
}
All of the fields work perfectly except for the "pd_size" field, for which I get the error message:
"Unknown column 'Medium' in 'field list'" or "Unknown column 'Small' in 'field list'" depending on the size chosen. I realise that it's looking for a column in the database called "Medium" instead of "product_size", but I can't see why...
Please help me out!
Thanks!
Tyrone