3v4l.org

run code in 300+ PHP versions simultaneously
<?php function updateGoals() { $response = array(); if(!empty($_POST)){ if(isset($_POST["actID"]) && isset($_POST["nutID"]) && isset($_POST["activityProgress"]) && isset($_POST["nutritionProgress"])){ $actID = intval($_POST["actID"]); $nutID = intval($_POST["nutID"]); $actProg = floatval($_POST["activityProgress"]); $nutProg = floatval($_POST["nutritionProgress"]); } $query = "UPDATE Goals SET Progress='$nutProg' WHERE GoalID=$nutID;"; $result = mysql_query($query) or die(mysql_error()); if ($result) { $response["error"] = false; $response["message"] = "Nutrtition goal updated successfully!"; } else { $response["error"] = true; $response["message"] = "Failed to update nutrtition goal!"; } $query = "UPDATE Goals SET Progress='$actProg' WHERE GoalID=$actID;"; $result = mysql_query($query) or die(mysql_error()); if ($result) { $response["error"] = false; $response["message"] = "Activity goal updated successfully!"; } else { $response["error"] = true; $response["message"] = "Failed to update activity goal!"; } if (isset($_POST["newgoalID"]) && isset($_POST["newgoal"]) && $isset($_POST["newgoalProgress"])) { $newGoalID = intval($_POST["newgoalID"]); $newgoal = $_POST["newgoal"]; $newGoalProg = floatval($_POST["newgoalProgress"]); $query = "UPDATE Goals SET Description='$newgoal',Progress='$newGoalProg' WHERE GoalID=$newGoalID;"; $result = mysql_query($query) or die(mysql_error()); } else if(isset($_POST["newgoal"]) && isset($_POST["pid"]) && isset($_POST["week"])) { $newgoal = $_POST["newgoal"]; $pid = intval($_POST["pid"]); $week = intval($_POST["week"]); $query = "INSERT INTO Goals (ParticipantID, Type, Description, WeekNumbe r) VALUES ('$pid', 'OTHER', '$newgoal', '$week');"; $result = mysql_query($query) or die(mysql_error()); } } else { $response["error"] = true; $response["message"] = "Things are missing!"; } // echo json response echo json_encode($response); } updateGoals(); ?>
Output for 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
{"error":true,"message":"Things are missing!"}
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6
Fatal error: Call to undefined function json_encode() in /in/JqHsJ on line 52
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: json_encode() in /in/JqHsJ on line 52
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.4
Fatal error: Call to undefined function: json_encode() in /in/JqHsJ on line 52
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: json_encode() in /in/JqHsJ on line 52

preferences:
342.25 ms | 401 KiB | 460 Q