3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getGoals(){ $link = mysql_connect('localhost','root','root'); mysql_select_db("goal_database",$link); if (isset($_GET["pid"]) && isset($_GET["week"])) { $pid = intval($_GET["pid"]); $week = intval($_GET["week"]); $response = array(); $response["goals"] = array(); // Mysql select query to retrieve nutrition goal $nutrition_result = mysql_query("SELECT Description FROM Goals WHERE ParticipantID=$pid AND WeekNumber=$week AND Type='NUTRITION';"); $row = mysql_fetch_array($nutrition_result); $nutrition_goal = $row[0]; $tmp = array(); $tmp["nutrition"] = $nutrition_goal; array_push($response["goals"], $tmp); // Mysql query to retrieve exervise goal $exercise_result = mysql_query("SELECT Description FROM Goals WHERE ParticipantID=$pid AND WeekNumber=$week AND Type='EXERCISE';"); $row = mysql_fetch_array($exercise_result; $exercise_goal = $row[0]; $tmp["exercise"] = $exercise_goal; array_push($response["goals"], $tmp); // keeping response header to json header('Content-Type: application/json'); // echnoing json result echo json_encode($response); if (mysql_errno()) { $error = "MySQL error ".mysql_errno().": ".mysql_error()."\n<br>When executing:<br>\n$query\n<br>"; echo $error; } } } getGoals(); ?>
Output for 5.3.0 - 5.3.28, 5.4.0 - 5.4.25
Parse error: syntax error, unexpected ';' in /in/6cn0R on line 20
Process exited with code 255.

preferences:
185.44 ms | 1395 KiB | 62 Q