title: PHP MySQL: Search database for string (in array) missing results
body: <p>I am creating a feature which searches a database for a string. The PHP shows no errors using a PHP validator and, if the search term doesn't exist, it returns the correct errors. My problem is that, when searching for the term 'abandon hastily' in the column of the database entitled 'collocation' (which is currently the only entry in the database), no results are returned. Though I can see using phpMyAdmin that this entry does definitely exist.</p>
  
  <p>The string is entered by a user into an input field using the following HTML:</p>
  
  <pre><code>&lt;form action='http://www.murkyfiles.esy.es/search.php' method='GET'&gt;
    &lt;center&gt;
      &lt;p&gt;&lt;label for='search'&gt;Please enter your question as accurately as possible:&lt;/label&gt;&lt;/p&gt;
      &lt;p&gt;&lt;input type='search' size='90' name='search'&gt;&lt;/p&gt;
      &lt;p&gt;&lt;input type='submit'  name='submit' value='Find answer'&gt;&lt;/p&gt;
    &lt;/center&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>The term entered is searched on the database using the following PHP:</p>
  
  <pre><code>&lt;?php
  $button = $_GET [ 'submit' ];
  $search = $_GET [ 'search' ];
  $host = "[HOST URL]";
  $username = "[USERNAME]";
  $password = "[PASSWORD]";
  $database = "[DATABASE]";
  $searchlength = strlen($search);
  
  if( !$button )
    echo "You didn't submit a keyword";
  else {
    if( strlen( $search ) &lt;= 1 )
      echo "Search term too short";
    else {
      echo "You searched for &lt;b&gt; $search &lt;/b&gt; &lt;hr size='1' &gt; &lt;/ br &gt; ";
  
      // Connect to database
  
      $con = mysqli_connect ( $host, $username, $password );
  
      if(!$con) {
          die('Could not connect: ' .PDO::errorInfo());
      }
  
      mysqli_select_db ( $con, $database );
  
      $search = str_split($search, $searchlength);
  
      $construct = " SELECT * FROM 'coll_test' WHERE collocation LIKE '%$search%' ";
  
      $run = mysqli_query( $con, $construct );
  
      //Fetch and return search results.
  
      if ($foundnum == 0)
          echo "Sorry, there are no matching results for &lt;b&gt; $search[0] &lt;/b&gt;.
          &lt;/ br &gt;
          &lt;/ br &gt; 1. Try presenting your Something is wrong in a more academic manner. Guidance can be found on the majority of University websites without need for registration.
          &lt;/ br &gt; 2. Try more common words/phrases with similar meaning. This search focuses on colloquialisms - commonly used phrases within a language.
          &lt;/ br &gt; 3. Please check your spelling";
  
      else {
        echo "$foundnum results found !&lt;p&gt;";
  
        while ( $runrows = mysqli_fetch_assoc($run) ) {
            $collocation = $runrows ['collocation'];
          echo "&lt;a href='$url'&gt; &lt;b&gt; $title &lt;/b&gt; &lt;/a&gt; &lt;br&gt; $desc &lt;br&gt; &lt;a href='$url'&gt; $url &lt;/a&gt; &lt;p&gt;";
        }
      }
    }
  }
  </code></pre>
  
  <p>I have looked at various similar questions and none of them offer solution.</p>
  
  <p>To clarify, the database table column headers are as follows:</p>
  
  <blockquote>
    <p><strong>collocation</strong> | <strong>left</strong> | <strong>right</strong> | <strong>length</strong> | <strong>google-results</strong> |  <strong>bing-results</strong> | <strong>yahoo-results</strong> | <strong>url-link</strong> | <strong>wiki</strong> | <strong>date</strong></p>
  </blockquote>
  
  <p>There is, so far, only one entry in my database:</p>
  
  <pre><code>collocation = abandon hastily
  left = abandon
  right = NULL
  length = 2
  google-results = 24000000
  bing-results = 386000
  yahoo-results = 385000
  url-link = oxforddictionary.so8848.com/search1?word=abandon
  wiki = 0
  date = [TIMESTAMP]
  </code></pre>