I have a mysql table: "append". There are these columns in each record:
id, weight, username, email, password
The weight column has a default NULL value. It is text type.
When I want to UPDATE the weight column and CONCAT it (when the value is still NULL), it does not work. There is no error and say it is successful. But there is no difference in the "weight" as I see in phpmyadmin after refresh.
But when I add values to weight by hand and after trying to UPDATE CONCAT it, it works perfectly.
How to modify the code to CONCAT it, when there is no value yet in "weight".
The problem may be with the NULL value! I do not want to add a default value to "weight".
Do I need an IF statement? But how?
What I have tried:
$sql = "UPDATE append SET weight = CONCAT(weight, ',$weight') WHERE id = '" . $_SESSION['user']['id'] . "'";
if ($conn->query($sql) === TRUE) {
echo "Successful!";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}