現時点では、動作している更新クエリを実行していますが、不要な null 値を挿入できます。
mysql_query('UPDATE community_table SET
age = "'.$age.'",
gender = "'.$gender.'",
pregnant = "'.$pregnant.'",
diet = "'.$diet.'",
smoker = "'.$smoker.'",
alcohol = "'.$alcohol.'",
exercise = "'.$exercise.'",
bmi = "'.$bmi.'",
sleeping = "'.$sleeping.'",
stress = "'.$stress.'",
education = "'.$education.'"
WHERE username = "' . $_SESSION['user'] . '" ');
null 値が入力されないように見えるこのクエリを試しましたが、変数が null でない場合に値が入力されるのも防ぎます。
age = "'.$age.'",
gender = "'.$gender.'",
pregnant = "'.$pregnant.'",
diet = "'.$diet.'",
smoker = "'.$smoker.'",
alcohol = "'.$alcohol.'",
exercise = "'.$exercise.'",
bmi = "'.$bmi.'",
sleeping = "'.$sleeping.'",
stress = "'.$stress.'",
education = "'.$education.'"
WHERE age IS NOT NULL,
gender IS NOT NULL,
pregnant IS NOT NULL,
diet IS NOT NULL,
smoker IS NOT NULL,
alcohol IS NOT NULL,
exercise IS NOT NULL,
bmi IS NOT NULL,
sleeping IS NOT NULL,
stress IS NOT NULL,
education IS NOT NULL and where
username = "' . $_SESSION['user'] . '" ');
上記のクエリに問題がありますか、それとも入力に null 値が含まれている可能性がありますか?
ありがとう。