title: Ambiguous PDO Statement - Php?
body: <p>So, I'm trying to get all the comments for a certain course. The way it tells what course has which comments is by the course.php?cID=1563 for example. The cID is the identifer which performs this distinction.</p>
  
  <p><strong>It keeps throwing this fatal error: Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'cID' in where clause is ambiguous' PDOStatement->execute(Array) #1 thrown on line 42</strong></p>
  
  <p><strong>DB Structure for (2) tables:</strong>
  <img src="https://i.stack.imgur.com/E1tsV.png" alt="tables"></p>
  
  <p><strong>PHP:</strong></p>
  
  <pre><code>&lt;?php
  // Get course information cID, prefix, code and dept info : name
  $cID = filter_input(INPUT_GET, 'cID', FILTER_SANITIZE_NUMBER_INT);
  if(!$cID) {
      echo "No cID specified.";
      exit;
  }
  $username = "###";
  $password = "###";
  $pdo2 = new PDO('mysql:host=localhost;dbname=####', $username, $password);
  $pdo2-&gt;setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
  $sth2 = $pdo2-&gt;prepare('
      SELECT Co.info, Co.date
      FROM Course C, Comment Co
      WHERE C.cID = Co.cID
      AND cID = ?;
      ;');
  $sth2-&gt;execute(array(
      $cID
  ));
  ?&gt;
  </code></pre>
  
  <p><strong>PHP Calling the above:</strong></p>
  
  <pre><code>&lt;?php
                      // Did we get any *course detail*
                      if($sth2-&gt;rowCount() &gt; 0) {
                          $row = $sth2-&gt;fetch(PDO::FETCH_ASSOC);
                          echo "&lt;img class='left' style='margin:5px;' src='img/courseComment.png'/&gt; &lt;p&gt; {$row['info']} &lt;/p&gt;";
                          } else {
                          echo "No results.";
                      }
                  unset($sth2);
                  ?&gt;
  </code></pre>
  
  <p>Why does this happen? If someone could please help me with an explanation and code fix that would be greatly appreciated. Also The url has the cID of the page.</p>