title: Cannot select where ip=inet_pton($ip)
body: <p>I have a unique column in database which is named <code>ip</code></p>
  
  <p>IP addresses are stored in this column as <code>BINARY(16)</code> (with no collation) after converting them using the PHP function </p>
  
  <pre><code>$store_ip = inet_pton($ip);
  </code></pre>
  
  <p>When I try to insert the same IP twice it works fine and fails because it is unique,</p>
  
  <p><strong>But</strong> when I try to select the IP it doesn't work and always returns FALSE (not found)</p>
  
  <pre><code>&lt;?php
  
  try {
      $ip = inet_pton($_SERVER['REMOTE_ADDR']);
      $stmt = $db-&gt;prepare("SELECT * FROM `votes` WHERE ip=?");
      $stmt-&gt;execute([$ip]);
      $get = $stmt-&gt;fetch();
  
      if( ! $get){
          echo 'Not found';
      }else{
          echo 'Found';
      }
  
      // close connection
      $get = null;
      $stmt = null;
  
  } catch (PDOException $e) {
      error_log($e-&gt;getMessage());
  }
  </code></pre>
  
  <p>The part where I insert the IP:</p>
  
  <pre><code>&lt;?php
  
  if( ! filter_var($ip, FILTER_VALIDATE_IP)){
          return FALSE;
  }
  
  $ip = inet_pton($_SERVER['REMOTE_ADDR']);
  
  try {
      $stmt = $db-&gt;prepare("INSERT INTO votes(ip, answer) VALUES(?,?)");
      $stmt-&gt;execute([$ip, $answer]);
      $stmt = null;
  } catch (PDOException $e) {
      return FALSE;
  }
  </code></pre>