Hi all,
I'm trying to run an update query using the following code:
<?php
require_once('myConnect/connect.php');
$email = mysqli_real_escape_string($dbc, $_GET['e']);
$ac = mysqli_real_escape_string($dbc, $_GET['ac']);
$checkQuery = "SELECT subscribed FROM myUsers WHERE email='$email'";
$checkQueryResult = @mysqli_query($dbc, $checkQuery);
$row = mysqli_fetch_assoc($checkQueryResult);
if ($row['subscribed'] == 1) {
echo '<p><b>This account has already been activated!</b></p>';
} else {
$updateQuery = "UPDATE myUsers SET subscribed=1, dateSubscribed=NOW() WHERE email='$email' AND ActivateCode='$ac'";
$updateQueryResult = @mysqli_query($dbc, $updateQuery);
if($updateQueryResult) {
echo '<p>Thank you! Your subscription is complete!</p>';
} else {
echo '<p>Subscription failed!</p>';
}
mysqli_free_result($updateQueryResult);
}
mysqli_free_result($checkQueryResult);
mysqli_close($dbc);
?>
I am getting the following output:
Thank you! Your subscription is complete!
Warning: mysqli_free_result() expects parameter 1 to be mysqli_result, boolean given in filepath/confirm.php on line 22
and the table is updated with the correct values.
From what I've read, this error is generated when the query fails. But how can that be so when the query runs and updates the table?
I'm confused.