3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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 7.0.5 - 7.2.0
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.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.3.19 - 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.