title: Parameterized Queries PHP/MySQL
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/583336/how-do-i-create-a-pdo-parameterized-query-with-a-like-statement-in-php">How do I create a PDO parameterized query with a LIKE statement in PHP?</a><br>
    <a href="https://stackoverflow.com/questions/1786436/php-pdo-prepared-statement-mysql-like-query">PHP PDO prepared statement &mdash; mysql LIKE query</a>  </p>
  </blockquote>
  
  
  
  <p>I'm trying to make a search engine for my website, and right now I'm just trying to make sure the connection is all and well.  Here is my code thus far:</p>
  
  <p><em>EDITED CODE (Still doesn't work, but here's where I'm at with the suggestions thus far):</em></p>
  
  <pre><code>$db = new PDO("mysql:host=".DB_SERVER.";dbname=".DB_NAME, DB_USER, DB_PASS);
  $stmt = $db-&gt;prepare("SELECT * FROM table_1 WHERE name LIKE ? ORDER BY bid DESC");
  $stmt-&gt;bindParam(1, "%{$_GET['s']}%", PDO::PARAM_STR);
  $stmt-&gt;execute();
  $rows = $stmt-&gt;fetchAll();
  </code></pre>
  
  <p>I tried to see if the different methods of <code>execute</code> would do anything, but regardless of which way above I write it, I get the same result, nothing.  I want the <code>%</code> wildcard in there so it does it'll search anywhere in <code>name</code>.  On that note, am I using it correctly?  The thing that confuses me most is when I type in the exact same query into PHPMyAdmin, the query runs through fine, so my guess is that I'm screwing up the PDO somewhere.</p>
  
  <hr>
  
  <p>EDIT: PHPMyAdmin Query:</p>
  
  <blockquote>
    <p>SELECT * 
    FROM table_1
    WHERE name LIKE  '%Test%'
    ORDER BY bid DESC 
    LIMIT 0 , 30</p>
  </blockquote>
  
  <p>This returns 1 result, as it is expected to.  What is different about my code and this query? :/</p>