3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function createNewNutritionGoal() { $response = array(); if (isset($_POST["pid"]) && isset($_POST["nutritionProgress"]) && isset($_POST["nutrition"]) && isset($_POST["week"])) { $pid = intval($_POST["pid"]); $nutrition = $_POST["nutrition"]; $nutritionProg = floatval($_POST["nutritionProgress"]); $week = intval($_POST["week"]); $query = "INSERT INTO Goals (ParticipantID, Type, Description, WeekNumber, P rogress) VALUES ('$pid', 'NUTRITION', '$nutrition', '$week', $nutritionProg');"; $result = mysql_query($query) or die(mysql_error()); if ($result) { $response["error"] = false; $response["message"] = "Nutrtition goal created successfully!"; } else { $response["error"] = true; $response["message"] = "Failed to create nutrtition goal!"; } } else { $response["error"] = true; $response["message"] = "Things are missing!"; } // echo json response echo json_encode($response); } ?>
Output for 4.3.0 - 7.2.0