Thereâs nothing obvious, but you said itâs been working and now does not, so that would suggest something data-related.
I donât understand why you have the UPDATE and SELECT queries after the insert, unless there could be more than one row containing the same values for auction_id
and all_clicked
. If you insert a row, thereâs no need to update that same row, and thereâs no need to SELECT it either. Just check that the insert query worked, and go from there.
Exactly that. Have a look at these two queries, you can see that in the first
//insert button click
$query = "INSERT INTO " . $DBPrefix . "buttonclicked (auction_id, all_clicked) VALUES(:auction_id, :all_clicked);";
$params = array();
$params[] = array(':auction_id', $id, 'int');
$params[] = array(':all_clicked', $_POST['all_clicked'], 'str');
$db->query($query, $params);
you clear the array before adding parameters to it, but in the next
//update button click
$query = "UPDATE " . $DBPrefix . "buttonclicked SET all_clicked = :all_clicked
WHERE auction_id = :auction";
$params[] = array(':all_clicked', $_POST['all_clicked'], 'int');
$params[] = array(':auction', $id, 'int');
$db->query($query, $params);
you donât, so by the time the update query is run, params()
now has four elements in it. If the code has been working before, then obviously your ->query()
function doesnât mind that.