title: mysqli prepared statement cannot read unicode
body: <p>Assume  <code>Adams’ Inn</code> <code>America’s Best Inn</code> stored in the db table <code>establishment</code></p>
  
  <p>I have to check  <code>Adams’ Inn</code> <code>America’s Best Inn</code> in a variable <code>$EstablishmentName</code></p>
  
  <pre><code>$stmt = $sql-&gt;prepare("SELECT ID FROM `establishment` WHERE Name=? LIMIT 1");
  $stmt-&gt;bind_param("s",$EstablishmentName);
  $stmt-&gt;execute();
  $stmt-&gt;store_result();
  print $stmt-&gt;num_rows;
  </code></pre>
  
  <p>The problem is I can't find them.</p>
  
  <p><strong>OUTPUT</strong> <code>0</code></p>
  
  <p><strong>Note</strong> enclosed <code>$EstablishmentName</code> with <code>mb_convert_string($EstablishmentName,'HTML-ENTITIES')</code> else you'll end up with error <code>Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '='</code></p>
  
  <p><strong>UPDATE:</strong> I use <code>set_charset('utf8')</code> for the client side; the table charset is utf8, and collation is <code>utf8_general_ci</code>. The text is encoded as what the original text is. I am using the following DB Manager: SQLyog and PHPMyAdmin.</p>
  
  <p><strong>UPDATE #2:</strong> I have attached the screenshot for you to look that I am telling the correct charset. </p>
  
  <p><img src="https://i.stack.imgur.com/9Uu2p.jpg" alt="screenshot_1"> </p>
  
  <p>I use <code>$sql-&gt;set_charset('utf-8');</code></p>
  
  <pre>
  Array
  (
      [BrandName] => America's Best Value Inn
      [try1] => 1
  )
  
  Array
  (
      [BrandName] => Adams' Inn
      [try1] => 0
  )
  
  Array
  (
      [BrandName] => Ambassador Inn and Suites
      [try1] => 1
  )
  
  Array
  (
      [BrandName] => Amberley Suite Hotel
      [try1] => 1
  )
  
  Array
  (
      [BrandName] => America's Best Value Inn
      [try1] => 0
  )
  </pre>
  
  <p><strong>UPDATE #3</strong> Ok, sorry. The column <code>Name</code> was <code>latin1_swedish_ci</code>.<br>
  I have updated the column <code>Name</code>:</p>
  
  <pre><code>ALTER TABLE establishment MODIFY NAME VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_general_ci;
  </code></pre>
  
  <p>This should work without the <code>mb_convert_string()</code> now.</p>