title: PHP: Undefined offset in stripos
body: <p><strong>Hello! Im working with AJAX with DB and when trying to render my db in an option and select tag it gives me an "Undefined offset error".</strong></p>
  
  <p>Here is my code:</p>
  
  <pre><code>$sql = "SELECT word FROM words";
  $result = mysql_query($sql);
  $response = "";
  $size = 0;
  
  if($result === FALSE) {
      die(mysql_error()); 
  }
  
  while ($row = mysql_fetch_array($result)) {
      for($i = 0; $i &lt; count($row); $i ++) {
          $pos = stripos(strtolower($row[$i]), $pattern); //Here marks the error
          if(!($pos === false)) {
            $size ++;
            $word = $row[$i];
            $response .= "&lt;option value=\"$word\"&gt;$word&lt;/option&gt;";
          }
      }
  }
  
  if($size &gt; 0) {
      echo "&lt;select id=\"list\" size=$size onclick=\"selectValue()\"&gt;$response&lt;/select&gt;";
  }
  </code></pre>
  
  <p>The idea of this app is you can start typing any word and it will search for words that matches with the input, displaying it first in an option HTML tag and when no more options are matched it's displayed in a select HTML tag. </p>
  
  <p>It's kind of working but it displays this errors. Can someone help me? Thanks!! </p>