3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Template Name: Q&A */ get_header(); ?> <?php require_once('db_connect.php'); $userIDmarker = $_SESSION['userID']; ?> <script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/jquery.validationEngine-en.js"></script> <script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/jquery.validationEngine.js"></script> <link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/css/validationEngine.jquery.css"> <script type="text/javascript"> function validateForm() { var x=document.forms["form1"]["Category"].value; if (x==null || x=="#") { alert("You must select a Category."); return false; } } jQuery(document).ready(function(){ jQuery("#form1").validationEngine('attach', {promptPosition : "topRight"}); jQuery(".deleteQuestion").click(function(){ var x = confirm("Are you sure want to delete this question?"); if(x){ var question_id = jQuery(this).attr('rel'); jQuery.ajax({ url:"<?php bloginfo("stylesheet_directory");?>/ajax.php?action=deleteQuestion", data:{question_id:question_id}, type:"POST", success:function(response){ if(response>0) jQuery("#box_"+question_id).remove(); } }); } }); jQuery(".deleteAns").click(function(){ var x = confirm("Are you sure want to delete this answer?"); if(x){ var answer_id = jQuery(this).attr('rel'); jQuery.ajax({ url:"<?php bloginfo("stylesheet_directory");?>/ajax.php?action=deleteAnswer", data:{answer_id:answer_id}, type:"POST", success:function(response){ if(response>0) jQuery("#answer_"+answer_id).remove(); } }); } }); $(".summary").keyup(function() { var len = jQuery(this).val().length; var max = 300; var left = 0; if (len <= max) { left = max - len; jQuery(this).siblings('.character_count').html("You have characters <span>" + left + "</span> left"); } }); $("#question_div").keyup(function() { var len = jQuery(this).val().length; var max = 140; var left = 0; if (len <= max) { left = max - len; jQuery('#character_count_question').html("You have characters <span>" + left + "</span> left"); } }); //document.write('<style type="text/css">input.styled { display: block; }</style>'); }); </script> <style> /* .character_count { margin-top: 17px !important; padding: 2px; } */ .character_count > span { color: red; } .character_count { float: right; margin-top: 4px; } #character_count_question { margin-right: 149px; margin-top: -11px; } </style> <?php if (isset($_POST['add'])) { if(!empty($_POST['hsecond_category'])) $level = $_POST['hsecond_category']; else $level = $_POST['Category']; $question = $_POST['singleQuestionContent']; $sqlCategory = "SELECT name from projectcategory WHERE catid = '$level'"; $resultCat = mysql_query($sqlCategory); $row = mysql_fetch_row($resultCat); $catName = $row[0]; $sql="INSERT INTO questions (Question, AuthorUserID, Category ) VALUES ('$question', '$userIDmarker','$catName');"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } else{ ?> <script> jQuery(document).ready(function(){ $('.darken').show(); show_permisson_project(); }); </script> <?php } } /* if (isset($_POST['upcomment']) && $_POST['Answer'] != "") { if ($_POST['currentcomment'] == "") { $updatedcomment = $_POST['Answer']. "^"; } else { $updatedcomment = $_POST['currentcomment'] . "^" . $_POST['Answer']; } $sql="UPDATE questions SET Answers='$updatedcomment' WHERE id = '$_POST[qid]'"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "<div class='updated'><p><strong>Updated!</strong> - Your comment has been added</p></div>"; } */ if(isset($_POST['submitAnswer'])){ $question_id = $_POST['qid']; $answer = $_POST['Answer']; $user_id = $_SESSION['userID']; $date = date('Y-m-d H:i:s',time()); $sql2 = "SELECT Question,AuthorUserID FROM questions WHERE id=$question_id"; $result2 = mysql_query($sql2); $data2 = mysql_fetch_assoc($result2); $question_title = $data2["Question"]; $sql = "SELECT EmailAddress FROM user WHERE UserID=".$data2['AuthorUserID']; $result = mysql_query($sql); $data = mysql_fetch_assoc($result); $authorEmail = $data["EmailAddress"]; $query = "INSERT INTO `qa_answers` " . "(`question_id`, `user_id`, `answer`, `date`, `status`) " . "VALUES ('$question_id', '$user_id', '$answer', '$date', '1');"; mysql_query($query); // multiple recipients $to = $authorEmail; //$to = "gilbert@123789.org"; // subject $subject = 'New answers posted'; $message = '<p>Dear User,<p><p>New comment posted on the <b><i>"'.$question_title.'"</i></b></p>'; $message .= '<p>Please click the link below to review.<br/> <a href="'.get_bloginfo("url").'/qa#box_'.$question_id.'">Click here</a>'; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: Hugyourhouse <amer@hugyourhouse.co.uk>' . "\r\n"; mail($to, $subject, $message, $headers); echo "<div class='updated'><p><strong>Updated!</strong> - Your comment has been added</p></div>"; } ?> <div id="inner_content"> <div class="page_content"> <h2 class="title"><?php the_title(); ?></h2> <?php if(!isset($_SESSION['username'])) { ?> <h5 style="float: right;margin: -57px 0 0 0;"><a class='footer_login' href='#login_wrap' >Login</a> today to ask your question</h5> <?php }?> <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?> <?php the_content(); ?> <?php endwhile; ?> <?php if(isset($_SESSION['username'])) { ?> <div class="questionaskBox"> <form id="form1" name="form1" method="post" action="" onsubmit="return validateForm();"> <h5>Ask your question today by entering it in the box below</h5> <p><strong>Step 1:</strong> Choose your Category</p> <p style="float: left;width: 621px;"> <select name="Category" id="qmain_category" class="art-select validate[required]" style=" " > <option value="">Select primary category</option> <option value="2">Build</option> <option value="3">Decor</option> <option value="4">Indoor</option> <option value="5">Outdoor</option> <option value="6">Go Green</option> </select> </p> <p style="float: left;width: 621px;"> <select name="hsecond_category" class="art-select validate[required]" id="qsecond_category"> <option value="">Select sub category</option> </select> </p> <p><strong>Step 2:</strong> Ask your Question</p> <p> <textarea name="singleQuestionContent" class="validate[required]" cols="60" rows="5" id="question_div" maxlength="140"></textarea> <div class="character_count" id="character_count_question">You have characters <span>140</span> left</div></p> <input name="add" type="hidden" value="add" /> <input name="Ask your Question" type="submit" value="Submit Question" class="buttonStyleAdd" style="float: left; margin-top: -32px;" id="qsubmit"/> </form> </div> <?php } ?> <?php if (isset($_GET['cat'])) {$questioninfo = mysql_query("SELECT * FROM questions WHERE Category = '$_GET[cat]'");} else {$questioninfo = mysql_query("SELECT * FROM questions order by id desc");} while( $row = mysql_fetch_array( $questioninfo ) ){ ?> <div class="questionBox" id="box_<?php echo $row['id'];?>"> <a name="box_<?php echo $row['id'];?>"></a> <script type="text/javascript"> $('#seeanswers<?php echo $row['id']; ?>').click(function(){ $('#hiddenComments<?php echo $row['id']; ?>').toggle(); }); $('#giveanswer<?php echo $row['id']; ?>').click(function(){ $('#giveanswerBox<?php echo $row['id']; ?>').toggle(); }); </script> <h2><?php echo $row['Question']; ?></h2> <?php $sql2 = "SELECT AuthorUserID FROM questions WHERE id=".$row['id']; $result2 = mysql_query($sql2); $data2 = mysql_fetch_assoc($result2); $AuthorUserID = $data2["AuthorUserID"]; if($AuthorUserID==$userIDmarker || $_SESSION['type']==5){ ?> <a title="Delete this question" rel="<?php echo $row['id'];?>" class="delete deleteQuestion" href="javascript:void(0);" style="float: right; margin-top: -38px;">Delete</a> <?php }?> <p>Category: <?php echo $row['Category']; ?> | Posted By <?php $userInfo = mysql_query("SELECT * FROM user WHERE UserID = '$row[AuthorUserID]' LIMIT 1"); while( $userdata = mysql_fetch_array( $userInfo ) ){echo $userdata['FirstName']." ".$userdata['LastName'];}?> </a></p> <a id="seeanswers<?php echo $row['id']; ?>" onclick="showorhide('hiddenComments<?php echo $row['id']; ?>')">See Answers</a> or <a id="giveanswer<?php echo $row['id']; ?>" onclick="showorhide('giveanswerBox<?php echo $row['id']; ?>')">Answer this Question</a> <div class="hiddenComments" id="hiddenComments<?php echo $row['id']; ?>"> <?php /*$answer = explode('^', $row['Answers']); $answercounter = 0; while ( $answercounter < 10) { if ($answer[$answercounter]) { echo "<li>".$answer[$answercounter]."</li>"; } if ($answer[$answercounter]== "") {$answercounter = 15;} else { $answercounter++;} } */?> <?php $ansQuery = "SELECT * FROM qa_answers WHERE question_id= ".$row['id']; $resultAns = mysql_query($ansQuery); while($ans = mysql_fetch_assoc( $resultAns )){ $sqlUser = "SELECT FirstName,UserID FROM user WHERE UserID=".$ans['user_id']; $resultUser = mysql_query($sqlUser); $dataUser = mysql_fetch_assoc($resultUser); $name = $dataUser["FirstName"]; $ID = $dataUser["UserID"]; echo "<li id='answer_".$ans['ID']."'>".$ans["answer"]."<br/><small>".date('Y-m-d',strtotime($ans["date"]))."<small> By <a href='".get_bloginfo('url')."/user-profile/?userID=$ID'>$name</a>"; if($ans['user_id']==$userIDmarker || $AuthorUserID==$userIDmarker || $_SESSION['type']==5){ echo "<a class='delete deleteAns' href='javascript:void(0);' rel='".$ans['ID']."' style='float:right;'>Delete</a>"; } echo "</li>"; } ?> </div> <div class="giveanswerBox" id="giveanswerBox<?php echo $row['id']; ?>"> <?php if(isset($_SESSION['username'])) { ?> <form id="form2" name="form2" method="post" action=""> <div class="answerCon"> <textarea name="Answer" cols="60" rows="5" class="summary" style="text-align: left;width:600px !important; float:left !important; background-color:#fff !important; height:200px;" maxlength="300"></textarea> <div class="character_count">You have characters <span>300</span> left</div> <br /><br /><br /> </div> <!-- <input name="currentcomment" type="hidden" value="<?php echo $row['Answers']; ?>" /> <input name="qid" type="hidden" value="<?php echo $row['id']; ?>" /><input name="upcomment" type="hidden" value="yes" />--> <!-- <input name="Ask your Question" type="submit" value="Submit answer" class="buttonStyleAdd" style="float: left; margin-top: -32px;"/>--> <input name="qid" type="hidden" value="<?php echo $row['id']; ?>" /> <input name="author_id" type="hidden" value="<?php echo $row['AuthorUserID ']; ?>" /> <input name="submitAnswer" type="submit" value="Submit answer" class="buttonStyleAdd" style="float: left; margin-top: -32px;"/> </form> <? } else { echo "<br/><h5><a class='footer_login' href='#login_wrap'>Login</a> today to answer this question</h5>"; }?> </div> </div> <div class="clear"></div><!--clear--> <?php }?> </div><!--page_content--> <div id="sidebar"> <h3 class="widgettitle">Latest Questions & Answers by Category</h3> <ul id="category_list"> <li><a href="?cat=Build">Build</a></li> <li><a href="?cat=Decor">Decor</a></li> <li><a href="?cat=Indoor">Indoor</a></li> <li><a href="?cat=Outdoor">Outdoor</a></li> <li><a href="?cat=Go Green">Go Green</a></li> </ul> <div class="advert"> <p><small>SPONSORED ADVERT</small></p> <div class="advert_image"> <?php if (function_exists('dfrads')) { echo dfrads('1961087'); } ?> </div><!--advert_image--> </div><!--advert--> </div><!--sidebar--> <div class="clear"></div><!--clear--> </div><!--inner_content--> <div id="question_post" style="z-index:99999999;display:none;"> <div class="not_now"> <a href="#" onclick="hide_permisson_project(); return false;">Close</a> </div> <div class="sep"></div> <h2>Your question has been posted successfully.</h2> <div class="sep"></div> </div> <script> function hide_permisson_project() { $('#question_post').hide(); $('.darken').hide(); } function show_permisson_project() { $('.darken').show(); $('#question_post').show(); } </script> <?php get_footer(); ?>
Output for 7.1.25 - 7.1.33, 7.2.0 - 7.2.24, 7.3.0 - 7.3.12
Parse error: syntax error, unexpected end of file in /in/B2oBW on line 386
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20
Fatal error: Uncaught Error: Call to undefined function get_header() in /in/B2oBW:5 Stack trace: #0 {main} thrown in /in/B2oBW on line 5
Process exited with code 255.
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28
Fatal error: Call to undefined function get_header() in /in/B2oBW on line 5
Process exited with code 255.

preferences:
145.29 ms | 402 KiB | 181 Q