title: Updating $_POST code to php7, isset issue?
body: <p>I'm getting this error after upgrading to php7, I've solved most issues.</p>
  
  <blockquote>
    <p>Error: You have an error in your SQL syntax; check the manual that
    corresponds to your MySQL server version for the right syntax to use
    near '' at line 1</p>
  </blockquote>
  
  <p>Here's the start of the code (this seems to be causing the issue). When the page is loaded $_POST is not set, there is a drop down (created from sql1), this result feeds into other sql queries later in the script.</p>
  
  <pre><code>&lt;?php include 'connect.php'; ?&gt;
  
  &lt;?php
  $post_pub = isset($_POST['site']) ?: $_POST['site'] = '';
  
  // Perform queries 
  $sql1="SELECT Site_ID, Site_name_1 FROM `Sites` ORDER BY `Sites`.`Site_ID` ASC"; 
  </code></pre>
  
  <p>Here's the full code</p>
  
  <pre><code>    &lt;?php
  error_reporting(E_ALL);
  ini_set('display_errors', 1);
  ?&gt;
  
  &lt;?php include 'header.php'; ?&gt; 
  &lt;div class='container'&gt; 
  &lt;?php include 'menu.php'; ?&gt; 
  &lt;?php include 'connect.php'; ?&gt;
  
  &lt;?php
  $post_pub = isset($_POST['site']) ?: $_POST['site'] = '';
  
  // Perform queries 
  $sql1="SELECT Site_ID, Site_name_1 FROM `Sites` ORDER BY `Sites`.`Site_ID` ASC"; 
  //$sql1="SELECT Site_ID, Site_name_1 FROM 'Sites' ORDER BY 'Sites'.'Site_ID' ASC"; 
  
  $sqltable1="SELECT Publications.Pub_ID, Publications.ART_TITEL FROM `Publications` where Pub_ID=$post_pub";
  $sqltable2="SELECT Aspects.Aspect, Aspect_Pub_join.Pub_ID FROM `Aspects` INNER JOIN `Aspect_Pub_join` ON Aspects.Aspect_ID=Aspect_Pub_join.Aspect_ID WHERE Aspect_Pub_join.Pub_ID=$post_pub"; 
  $sqltable3="SELECT Publications.Pub_ID, Questions.Question FROM `Publications` LEFT JOIN `Aspect_Pub_join` ON Publications.Pub_ID=Aspect_Pub_join.Pub_ID LEFT JOIN `Aspect_question_join` ON Aspect_Pub_join.Aspect_ID=Aspect_question_join.Aspect_ID LEFT JOIN `Questions` ON Aspect_question_join.Question_ID=Questions.Question_ID Where Publications.Pub_ID=$post_pub GROUP BY Question ORDER BY Publications.Pub_ID ASC";
  
  $sqltable4="SELECT Publications.Pub_ID, Publications.ART_TITEL FROM `Publications` where Pub_ID=$post_pub"; 
  $sqltable5="SELECT Publications.Pub_ID, Publications.ART_TITEL FROM `Publications` where Pub_ID=$post_pub"; 
  
  $result1=mysqli_query($mysqli, $sql1) or die("Error: ".mysqli_error($mysqli));
  
  $result_table1=mysqli_query($mysqli, $sqltable1) or die("Error: ".mysqli_error($mysqli));
  $result_table2=mysqli_query($mysqli, $sqltable2) or die("Error: ".mysqli_error($mysqli));
  $result_table3=mysqli_query($mysqli, $sqltable3) or die("Error: ".mysqli_error($mysqli));
  $result_table4=mysqli_query($mysqli, $sqltable4) or die("Error: ".mysqli_error($mysqli));
  $result_table5=mysqli_query($mysqli, $sqltable5) or die("Error: ".mysqli_error($mysqli));
  
  
  
  $site_array = array();
  
  while (list($id, $name) = mysqli_fetch_row($result1)) {$site_array[$id] = $name;}
  
  
  //// Free result set
  //mysqli_free_result($result);
  
  function get_options($arr, $current=null) 
  {
      $opts = '';
      foreach ($arr as $k =&gt; $v) {
          $sel = $k==$current ? 'selected="selected"' : '';
          $opts .= "&lt;option value='$k'  $sel&gt;$k $v&lt;/option&gt;\n";
  
      }
      return $opts;
  }
  
  
  
  ?&gt;
  
  &lt;html&gt;
  &lt;body&gt;
  &lt;br/&gt;
  &lt;form action="&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;" method="POST"&gt;
    &lt;select name="site" onchange="this.form.submit();"&gt;
  &lt;?php echo"&lt;option&gt;Select Site&lt;/option&gt;";?&gt;
      &lt;?php echo get_options($site_array);?&gt;
  
    &lt;/select&gt;
  
  
  
  &lt;/form&gt;
  &lt;br/&gt;
  
  &lt;p&gt; Displaying all information for:&lt;?php if(isset($_POST['site'])){echo $_POST['site'];} ?&gt;&lt;/p&gt;
  
  
  
  &lt;div style="void:both;";&gt;&lt;/div&gt;
  
  
  
  &lt;div class='table_holder'&gt;
    &lt;div class='table' style='height:100px; margin-right:20px;'&gt;
      &lt;table width='100%' align='center' id='table1' class='tablesorter'&gt;
        &lt;thead&gt;
          &lt;tr&gt;
            &lt;th&gt;Publication Title&lt;/th&gt;
          &lt;/tr&gt;
        &lt;/thead&gt;
  
  
  
  &lt;?php while($rows1=mysqli_fetch_array($result_table1)){ ?&gt;
          &lt;tr&gt;
            &lt;td&gt;&lt;?php echo $rows1['ART_TITEL']; ?&gt;&lt;/td&gt;
          &lt;/tr&gt;
  &lt;?php } ?&gt;
  
      &lt;/table&gt;
    &lt;/div&gt; 
  &lt;/div&gt; 
  
  
  &lt;br/&gt;&lt;br/&gt;
  &lt;div style="void:both;";&gt;&lt;/div&gt;
  &lt;br/&gt;&lt;br/&gt;
  
  &lt;div class='table_holder'&gt;
    &lt;div class='table' style='height:200px;'&gt;
      &lt;table width='100%' align='center' id='table2' class='tablesorter'&gt;
        &lt;thead&gt;
          &lt;tr&gt;
            &lt;th&gt;Aspects&lt;/th&gt;
          &lt;/tr&gt;
        &lt;/thead&gt;
  
  &lt;?php while($rows2=mysqli_fetch_array($result_table2)){ ?&gt;
          &lt;tr&gt;
            &lt;td&gt;&lt;?php echo $rows2['Aspect']; ?&gt;&lt;/td&gt;
          &lt;/tr&gt;
  &lt;?php } ?&gt;
  
      &lt;/table&gt;
    &lt;/div&gt; 
  &lt;/div&gt; 
  
  &lt;br/&gt;&lt;br/&gt;
  &lt;div style="void:both;";&gt;&lt;/div&gt;
  &lt;br/&gt;&lt;br/&gt;
  
  &lt;div class='table_holder'&gt;
    &lt;div class='table' style='height:200px;'&gt;
      &lt;table width='100%' align='center' id='table3' class='tablesorter'&gt;
        &lt;thead&gt;
          &lt;tr&gt;
            &lt;th&gt;Question&lt;/th&gt;
          &lt;/tr&gt;
        &lt;/thead&gt;
  &lt;?php while($rows3=mysqli_fetch_array($result_table3)){ ?&gt;
          &lt;tr&gt;
            &lt;td&gt;&lt;?php echo $rows3['Question']; ?&gt;&lt;/td&gt;
          &lt;/tr&gt;
  &lt;?php } ?&gt;
  
      &lt;/table&gt;
    &lt;/div&gt; 
  &lt;/div&gt; 
  
  
  
  
  
  
  &lt;?php include 'footer.php' ?&gt;
  </code></pre>