title: PHP search with multiple drop down boxes
body: <p>I am making a search box with multiple drop down boxes.
  Here is the main page:</p>
  
  <pre><code>&lt;div id="wrapper"&gt;
      &lt;form action="search2.php" method="post"&gt;
          &lt;select name="user"&gt;
              &lt;option value="" selected="selected"&gt;All Users&lt;/option&gt;
              &lt;option value="tom"&gt;tom&lt;/option&gt;
              &lt;option value="bob"&gt;bob&lt;/option&gt;
          &lt;/select&gt;
          &lt;select name="city"&gt;
              &lt;option value="" selected="selected"&gt;All cities&lt;/option&gt;
              &lt;option value="NY"&gt;NY&lt;/option&gt;
              &lt;option value="NA"&gt;LA&lt;/option&gt;
          &lt;/select&gt;
      &lt;input type="submit" value="search" /&gt;
      &lt;/form&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>And here is the search2.php</p>
  
  <pre><code>&lt;?php
  include('includes/db_AF.php'); //includes the db credentials
  $connection = @new mysqli(HOSTNAME, MYSQLUSER, MYSQLPASS, MYSQLDB);
  
  
  $whereClauses = array(); 
  if (! empty($_POST['user'])) $whereClauses[] ="user='".mysqli_real_escape_string($_POST['user'])."'"; 
  if (! empty($_POST['city'])) $whereClauses[] ="city='".mysqli_real_escape_string($_POST['city'])."'"; 
  $where = ''; 
  if (count($whereClauses) &gt; 0) { $where = ' WHERE '.implode(' AND ',$whereClauses); }
  
  $sql = mysqli_query("SELECT * FROM profile " .$where." ORDER BY user "); 
  
  $result=mysqli_query($sql);
  or die("Error: ".mysql_error()."&lt;br /&gt;Query: ".$sql);
  
  while ($row = mysqli_fetch_assoc($result)) {
  echo $row['user'];
  echo $row['city'];
  } 
  ?&gt;
  </code></pre>
  
  <p>I get error messages saying:</p>
  
  <ul>
  <li><p>mysqli_real_escape_string() expects exactly 2 parameters, 1 given</p></li>
  <li><p>mysqli_query() expects at least 2 parameters, 1 given</p></li>
  </ul>
  
  <p>What am I doing wrong?</p>