title: symfony 2 error - persisting data to a database
body: <p>I get a message : "Oops! An Error Occurred
  The server returned a "500 Internal Server Error".
  Something is broken. Please e-mail us at [email] and let us know what you were doing when this error occurred. We will fix it as soon as possible. Sorry for any inconvenience caused" when persisting data to a database. Here is a controller:</p>
  
  <pre class="lang-php prettyprint-override"><code>public function registerAction()
  {
      $register = new Register();
      $form = $this-&gt;createForm(new RegisterType(), $register);
  
      $request = $this-&gt;getRequest();
      if ($request-&gt;getMethod() == 'POST') 
      {
          $form-&gt;bindRequest($request);
  
          if ($form-&gt;isValid()) 
          {
              $em = $this-&gt;getDoctrine()-&gt;getEntityManager();
              $em-&gt;persist($register);
              $em-&gt;flush();
  
              return $this-&gt;redirect($this-&gt;generateUrl('ShopMyShopBundle_register'));
          }
      }
  
      return $this-&gt;render('ShopMyShopBundle:Main:register.html.twig', array('form' =&gt; $form-&gt;createView()));
  }
  </code></pre>
  
  <p>Where is the problem ?</p>