title: Writing this MySQLi query as a prepared statement
body: <p>I have an existing MySQLi query:</p>
  
  <pre><code>$conn = dbConnect('query');
  $galNumb = "SELECT COUNT(pj_gallery_id) FROM pj_galleries WHERE project = {$project}";
  $gNumb = $conn-&gt;query($galNumb);
  $row = $gNumb-&gt;fetch_row();
  $galTotal = $row[0];
  </code></pre>
  
  <p>This counts the number of galleries per project that match the value in the query string contained in $project.</p>
  
  <p>It works perfect but is not secure compared to a prepared statement. I have been researching this for two days and can not learn how to write this statement as a prepared statement. Any and all help will be insanely appreciated.</p>
  
  <p><strong>UPDATE:</strong>
  I am flying by the seat of my pants here. I simply need to be shown how to code the above as a prepared statement. This sort of thing isn't resonating with my brain like learning PHP did and I'm just not getting any of this. The PHP manual is confusing and seems to be written for people who already understand PHP.</p>
  
  <p>In short, I need a prepared statement version of the above code so that I can echo the result on the page. Currently, with what is in my DB, the number should be 3, and it consistently returns 1.</p>
  
  <p>I wish I knew more so that I could better phrase my questions, but alas, I'm still learning. My apologies.</p>
  
  <p><strong>UPDATE 2:</strong>
  Based on suggestions and research, I have this query written, but it ALWAYS returns the value 1, regardless of what's actually in the database:</p>
  
  <pre><code>$galNumb = "SELECT COUNT(pj_gallery_id) FROM pj_galleries WHERE project_part = ?";
  $stmt = $conn-&gt;prepare($galNumb);
  $stmt-&gt;bind_param('i', $project);
  $gNumb = $stmt-&gt;execute();
  </code></pre>
  
  <p>Again, All I want to do is COUNT how many galleries are in each project. I know this should be simple but it isn't for me. There is currently 1 project in the DB with 3 galleries. The query should return 3.</p>