3v4l.org

run code in 300+ PHP versions simultaneously
<?php include_once("../includes/db_connect.php"); $topic = $_POST['topic']; $query = $mysqli->query("select * from topic_answer where topic_name = '$topic' "); echo "<form action='#' method='POST'>"; echo '<input type="hidden" name="topic" value="' . $topic . '"/>'; echo '<label> Question </label>'; echo '<input type="text" id="Question" name="Question">'; echo '<br>'; echo '<label> is this a yes or no response? </label>'; echo '<select name="yes_no"> <option value=""></option> <option value="yes">yes</option> <option value="no">no</option> </select> '; echo '<br>'; echo '<label> Parent question </label>'; echo "<select name='parent'>"; while($obj = $query->fetch_object()){ echo $obj->id; echo "<br>"; echo $obj->topic_name; echo "<br>"; echo $obj->topic_question; echo "<br>"; echo "<option value='" . $obj->id . "'>" . $obj->topic_question . "</option>"; } echo '</select>'; echo '<button type="submit" name="submit" id="submit" value="submit">Submit</button>'; echo "</form>"; echo "<br>"; if(isset($_POST['submit'])){ $question = isset($_POST['Question']); $yes_no = isset($_POST['yes_no']); $parent = isset($_POST['parent']); if(empty($question)){ echo "error: question not set"; var_dump($question); }elseif(empty($yes_no)){ echo "error: yes or no not set"; } elseif(empty($parent)){ echo "error: parent not set"; } else{ $question = $_POST['Question']; $yes_no = $_POST['yes_no']; $parent = $_POST['parent']; if($yes_no === "yes"){ $yes = 1; $no = 0; }else{ $yes = 0; $no = 1; } $creator = "jordan"; $start = 0; $end = 0; var_dump($question); var_dump($yes_no); var_dump($parent); $insert = $mysqli->prepare("INSERT INTO topic_answer (topic_name, topic_creator, topic_question, load_yes, start, load_no, end, parent) values(?,?,?,?,?,?,?,?)"); $insert->bind_param('sssiiiii', $topic, $creator ,$question,$yes,$start,$no,$end,$parent); $insert->execute(); $insert->close(); } }
Output for 8.0.0 - 8.0.12, 8.0.14 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Warning: include_once(): open_basedir restriction in effect. File(../includes/db_connect.php) is not within the allowed path(s): (/tmp:/in:/etc) in /in/2emfO on line 3 Warning: include_once(../includes/db_connect.php): Failed to open stream: Operation not permitted in /in/2emfO on line 3 Warning: include_once(): Failed opening '../includes/db_connect.php' for inclusion (include_path='.:') in /in/2emfO on line 3 Warning: Undefined array key "topic" in /in/2emfO on line 5 Warning: Undefined variable $mysqli in /in/2emfO on line 7 Fatal error: Uncaught Error: Call to a member function query() on null in /in/2emfO:7 Stack trace: #0 {main} thrown in /in/2emfO on line 7
Process exited with code 255.
Output for 8.0.13
Warning: include_once(../includes/db_connect.php): Failed to open stream: No such file or directory in /in/2emfO on line 3 Warning: include_once(): Failed opening '../includes/db_connect.php' for inclusion (include_path='.:') in /in/2emfO on line 3 Warning: Undefined array key "topic" in /in/2emfO on line 5 Warning: Undefined variable $mysqli in /in/2emfO on line 7 Fatal error: Uncaught Error: Call to a member function query() on null in /in/2emfO:7 Stack trace: #0 {main} thrown in /in/2emfO on line 7
Process exited with code 255.
Output for 7.0.5 - 7.0.20, 7.1.0 - 7.1.10, 7.4.33
Warning: include_once(../includes/db_connect.php): failed to open stream: No such file or directory in /in/2emfO on line 3 Warning: include_once(): Failed opening '../includes/db_connect.php' for inclusion (include_path='.:') in /in/2emfO on line 3 Notice: Undefined index: topic in /in/2emfO on line 5 Notice: Undefined variable: mysqli in /in/2emfO on line 7 Fatal error: Uncaught Error: Call to a member function query() on null in /in/2emfO:7 Stack trace: #0 {main} thrown in /in/2emfO on line 7
Process exited with code 255.
Output for 7.1.25 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.32
Warning: include_once(): open_basedir restriction in effect. File(../includes/db_connect.php) is not within the allowed path(s): (/tmp:/in:/etc) in /in/2emfO on line 3 Warning: include_once(../includes/db_connect.php): failed to open stream: Operation not permitted in /in/2emfO on line 3 Warning: include_once(): Failed opening '../includes/db_connect.php' for inclusion (include_path='.:') in /in/2emfO on line 3 Notice: Undefined index: topic in /in/2emfO on line 5 Notice: Undefined variable: mysqli in /in/2emfO on line 7 Fatal error: Uncaught Error: Call to a member function query() on null in /in/2emfO:7 Stack trace: #0 {main} thrown in /in/2emfO on line 7
Process exited with code 255.
Output for 7.3.32 - 7.3.33
Warning: include_once(../includes/db_connect.php): failed to open stream: No such file or directory in /in/2emfO on line 3 Warning: include_once(): Failed opening '../includes/db_connect.php' for inclusion (include_path='.:') in /in/2emfO on line 3 Fatal error: Uncaught Error: Call to a member function query() on null in /in/2emfO:7 Stack trace: #0 {main} thrown in /in/2emfO on line 7
Process exited with code 255.
Output for 7.1.20
Warning: include_once(): open_basedir restriction in effect. File(../includes/db_connect.php) is not within the allowed path(s): (/tmp:/in) in /in/2emfO on line 3 Warning: include_once(../includes/db_connect.php): failed to open stream: Operation not permitted in /in/2emfO on line 3 Warning: include_once(): Failed opening '../includes/db_connect.php' for inclusion (include_path='.:') in /in/2emfO on line 3 Notice: Undefined index: topic in /in/2emfO on line 5 Notice: Undefined variable: mysqli in /in/2emfO on line 7 Fatal error: Uncaught Error: Call to a member function query() on null in /in/2emfO:7 Stack trace: #0 {main} thrown in /in/2emfO on line 7
Process exited with code 255.
Output for 7.0.0 - 7.0.4
Warning: include_once(../includes/db_connect.php): failed to open stream: No such file or directory in /in/2emfO on line 3 Warning: include_once(): Failed opening '../includes/db_connect.php' for inclusion (include_path='.:') in /in/2emfO on line 3 Notice: Undefined index: topic in /in/2emfO on line 5 Notice: Undefined variable: mysqli in /in/2emfO on line 7 Fatal error: Uncaught Error: Call to a member function query() on unknown in /in/2emfO:7 Stack trace: #0 {main} thrown in /in/2emfO on line 7
Process exited with code 255.
Output for 5.6.8 - 5.6.28
Warning: include_once(../includes/db_connect.php): failed to open stream: No such file or directory in /in/2emfO on line 3 Warning: include_once(): Failed opening '../includes/db_connect.php' for inclusion (include_path='.:') in /in/2emfO on line 3 Notice: Undefined index: topic in /in/2emfO on line 5 Notice: Undefined variable: mysqli in /in/2emfO on line 7 Fatal error: Call to a member function query() on null in /in/2emfO on line 7
Process exited with code 255.
Output for 5.4.0 - 5.4.45, 5.5.24 - 5.5.35
Warning: include_once(../includes/db_connect.php): failed to open stream: No such file or directory in /in/2emfO on line 3 Warning: include_once(): Failed opening '../includes/db_connect.php' for inclusion (include_path='.:') in /in/2emfO on line 3 Notice: Undefined index: topic in /in/2emfO on line 5 Notice: Undefined variable: mysqli in /in/2emfO on line 7 Fatal error: Call to a member function query() on a non-object in /in/2emfO on line 7
Process exited with code 255.

preferences:
214.83 ms | 402 KiB | 273 Q