CODE
$ipquery = "SELECT * FROM `tbl_pinsnew` WHERE `pin` = '$pin'";
$result = mysqli_query($mysqli,$ipquery) or die(mysql_error());
if (empty($row['IP'])) {
$stmt = $mysqli->prepare("UPDATE `tbl_pinsnew` SET `IP` = ? WHERE `pin` = ?");
$stmt->bind_param('ss', $ip, $pin);
$stmt->execute();
$stmt->close();
}else{
$stmt = $mysqli->prepare("UPDATE `tbl_pinsnew` SET `Shared` = ? WHERE `pin` = ?");
$stmt->bind_param('ss', 'True', $pin);
$stmt->execute();
$stmt->close();
}
So I have the above code, what it is supposed to do is go into the database, select the row with the matching pin, this part works fine, however it is supposed to check if the IP column is blank, if so update it, if the IP column has something in it, then it should move into the else statement.
Currently if just keeps going into the loop of the IF statement, even when the IP column isn't blank it just thinks it is, so re updates the IP column, when in fact it should move into the else statement
source https://stackoverflow.com/questions/76799174/mysql-checking-if-row-empty
No comments:
Post a Comment