title: SQL UPDATE query executes correctly via MySQL Workbench but not via PHP
body: <p>I have the following SQL query:</p>
  
  <pre><code>UPDATE uploads SET UserName='Test2', UserEmail='Test2', UploadCount='4' 
  WHERE Country = 'Algeria'
  </code></pre>
  
  <p>When I run this query via MySQL workbench it executes fine.</p>
  
  <p>I am trying to run this via a website / PHP however, and am attempting to execute the query in the following way:</p>
  
  <pre><code>$sql = "UPDATE uploads SET UserName='$user_data[name]', UserEmail='$user_data[email]', UploadCount='$user_data[FilesUploaded]' WHERE Country = '$country'";
  
  
  echo $sql;  
      try 
  
      {
      $pdo = new PDO('mysql:host=localhost; dbname=db01', $username, $password);
      $pdo-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  
      $stmt = $pdo-&gt;prepare($sql);
      $stmt-&gt;execute();       
  
    # Affected Rows?
        echo $stmt-&gt;rowCount(); // 1
      } catch(PDOException $e) {
        echo 'Error: ' . $e-&gt;getMessage();
      }
  </code></pre>
  
  <p>The SQL query is being built via variables here, however I copy / pasted the echo of $sql into workbench to check that there were no syntax errors creeping in, the echo of $sql is what I pasted above.</p>
  
  <p>When I run it via the web application, I get 0 row affected and the UPDATE is not made, where am I going wrong?</p>
  
  <p>Thank you</p>
  
  <p>UPDATE: A new paramatarized version of the PDO:</p>
  
  <pre><code>$sql =  "UPDATE uploads SET ";
  
  $sql .="UserName = :name, 
          UserEmail = :email, 
          UploadCount = :FilesUploaded";
  
  $sql .=" WHERE Country = '$country'";
  
      try     
      {
      $pdo = new PDO('mysql:host=localhost; dbname=db01', $username, $password);
      $pdo-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  
      $stmt = $pdo-&gt;prepare($sql);
  
      $stmt-&gt;bindParam(":name", $user_data['name']);
      $stmt-&gt;bindParam(":email", $user_data['email']);
      $stmt-&gt;bindParam(":FilesUploaded", $user_data['FilesUploaded']);
  
      $stmt-&gt;execute();       
  
    # Affected Rows?
        echo $stmt-&gt;rowCount(); // 1
      } catch(PDOException $e) {
        echo 'Error: ' . $e-&gt;getMessage();
      }
  </code></pre>