I’m sure there are other posts about this, but I can’t figure why the first INSERT works and the second INSERT gives me the stupid error… :mad:
if ( !$isSecondHandItem )
{
$sql = "INSERT INTO
Catalogue
(
Title,
Author,
Price,
Publisher,
Description,
Format,
Available,
DisplayOnIndex,
Category,
Image,
SubCategory,
offer,
Weight
)
VALUES
( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )";
}
else
{
$sql = "INSERT INTO
secondhandBooks
(
bookTitle,
bookAuthor,
condition,
price,
Available,
Weight,
Publisher,
Description,
Format
)
VALUES
( ?, ?, ?, ?, ?, ?, ?, ?, ? )";
}
// fetch the data from the DB
if ( ! $stmt = $db->prepare($sql))
{
$feedback = $stmt->error;
}
else
{
if ( !$isSecondHandItem )
{
$stmt->bind_param('ssissiisiiiii', $fTitle, $fAuthor, $fPrice, $fPublisher, $fDescription, $fFormat, $fAvailable, $fNewAddition, $fCategory, $fImage, $fSubCategory, $fFreeDelivery, $fWeight);
}
else
{
$stmt->bind_param('ssiiiissi', $fTitle, $fAuthor, $fCondition, $fPrice, $fAvailable, $fWeight, $fPublisher, $fDescription, $fFormat);
}
if ( ! $stmt->execute())
{
$feedback = $stmt->error;
}
else
{
$_SESSION['updatefeedback'] = '<p>Item was added</p>';
$stmt->close();
}
}
$db->close();
Please can someone help me with this? It makes no sense.