title: PHP error when updating MySQL row with PDO
body: <p>I'm trying to make a way to edit my posts on a blog I'm making but for some reason when I try to submit the "update post" form it will give me the error "Something went wrong..." (meaning it got to update post.php) and I'm not sure why. The only thing I could see it being is because I'm using TinyMCE to edit the content of the post and the way I'm doing it is wrong?</p>
  
  <p>editpost.php</p>
  
  <pre><code>    &lt;?php
        include 'php/mysql_connect.php'; // opens a PDO of variable $db
        if(isset($_GET['id'])){
          $q = $db-&gt;prepare('SELECT * FROM posts WHERE id=:post_id LIMIT 1');
          $q-&gt;execute(array(':post_id'=&gt;$_GET['id']));
          $row = $q-&gt;fetch(PDO::FETCH_ASSOC);
  
          if($row){
            echo '&lt;form method="post" action="php/update_post.php?post_id='.$_GET['id'].'"&gt;';
            echo '&lt;div class="form-group"&gt;';
            echo '  &lt;input type="text" class="form-control" name="title" id="title" placeholder="Post Title" autocomplete="off" value="'.$row['title'].'" required /&gt;';
            echo '&lt;/div&gt;';
            echo '&lt;div class="form-group"&gt;';
            echo '  &lt;textarea class="form-control" name="body" id="body"&gt;'.$row['body'].'&lt;/textarea&gt;';
            echo '&lt;/div&gt;';
            echo '&lt;input type="submit" value="Update Post" class="btn btn-default" /&gt;';
            echo '&lt;/form&gt;';
          }
          else{
            echo 'Post not found.';
          }
        }
        else{
          echo 'Post not found.';
        }
      ?&gt;
  </code></pre>
  
  <p>update_post.php</p>
  
  <pre><code>&lt;?php
  $post_id = $_GET['post_id'];
  $title = $_POST['title'];
  $body = $_POST['body'];
  include 'mysql_connect.php'; // establishes $db, a PDO connection
  
  // insert the records
  $sql = "UPDATE posts SET title=:title, body=:body WHERE id=:post_id)";
  $q = $db-&gt;prepare($sql);
  if($q-&gt;execute(array(':title'=&gt;$title, ':body'=&gt;$body, ':post_id'=&gt;$post_id))){
    echo '&lt;script type="text/javascript"&gt;alert("Success!");location.href="../posts.php";&lt;/script&gt;';
  }
  else{
    echo '&lt;script type="text/javascript"&gt;alert("Something went wrong...");location.href="../posts.php";&lt;/script&gt;';
  }
  ?&gt;
  </code></pre>
  
  <p>I've changed the form method to GET, and it is passing the variables correctly, so that isn't the problem. The update_post.php is a modified version of my add_post.php, which works perfectly fine so I don't understand why updating it doesn't work right.</p>