title: Cake php SQLSTATE[42000]: Syntax error or access violation: 1064
body: <p>I got this error while adding users.</p>
  
  <p>I have a view <strong>adduser.ctp</strong></p>
  
  <p>and in the User controller I have this function</p>
  
  <pre><code> public function addUser() {
      $userGroups = $this-&gt;UserGroup-&gt;getGroups();
      unset($userGroups[1]);
      unset($userGroups[2]);
      $this-&gt;set('userGroups', $userGroups);
      if ($this-&gt;request-&gt;isPost()) {
          $this-&gt;User-&gt;set($this-&gt;data);
          if ($this-&gt;User-&gt;AddEditValidate()) {
              $this-&gt;request-&gt;data['User']['email_verified'] = 1;
              $this-&gt;request-&gt;data['User']['active'] = 2;
              $this-&gt;request-&gt;data['User']['parent_id'] = $this-&gt;Session-&gt;read('logged_client_id');
              $salt = $this-&gt;UserAuth-&gt;makeSalt();
              $this-&gt;request-&gt;data['User']['salt'] = $salt;
              $this-&gt;request-&gt;data['User']['temp_password'] = $this-&gt;request-&gt;data['User']['password'];
              $this-&gt;request-&gt;data['User']['password'] = $this-&gt;UserAuth-&gt;makePassword($this-&gt;request-&gt;data['User']['password'], $salt);
              if ($this-&gt;User-&gt;save($this-&gt;request-&gt;data, false)) {
                  $this-&gt;sendLoginEmail($this-&gt;request-&gt;data['User']);
                  $this-&gt;Session-&gt;setFlash(__('The user is successfully added'), 'success_flash');
                  $this-&gt;redirect('/clientUsers/' . $this-&gt;Session-&gt;read('logged_client_id'));
              } else {
                  $this-&gt;Session-&gt;setFlash(__('Problem in saving user information'), 'error_flash');
              }
          }
      }
  }
  </code></pre>
  
  <p>Now in User model I validate by the following function</p>
  
  <pre><code>function AddEditValidate() {
      $validate1 = array(
          "user_group_id" =&gt; array(
              'rule' =&gt; array('comparison', '!=', 0),
              'message' =&gt; 'Please select group'),
          'first_name' =&gt; array(
              'mustNotEmpty' =&gt; array(
                  'rule' =&gt; 'notEmpty',
                  'message' =&gt; 'Please enter first name'),
              'custom' =&gt; array(
                  'rule' =&gt; 'alphaNumericSpace',
                  'message' =&gt; 'First name should be alphnumeric')
          ),
          'last_name' =&gt; array(
              'mustNotEmpty' =&gt; array(
                  'rule' =&gt; 'notEmpty',
                  'on' =&gt; 'create',
                  'message' =&gt; 'Please enter last name'),
              'custom' =&gt; array(
                  'rule' =&gt; 'alphaNumericSpace',
                  'message' =&gt; 'Last name should be alphnumeric')
          ),
          'email' =&gt; array(
              'mustNotEmpty' =&gt; array(
                  'rule' =&gt; 'notEmpty',
                  'message' =&gt; 'Please enter email',
                  'last' =&gt; true),
              'mustBeEmail' =&gt; array(
                  'rule' =&gt; array('email'),
                  'message' =&gt; 'Please enter valid email',
                  'last' =&gt; true),
              'mustUnique' =&gt; array(
                  'rule' =&gt; 'isEmailUnique',
                  'message' =&gt; 'This email is already registered',
              )
          ),
          'oldpassword' =&gt; array(
              'mustNotEmpty' =&gt; array(
                  'rule' =&gt; 'notEmpty',
                  'message' =&gt; 'Please enter old password',
                  'last' =&gt; true),
              'mustMatch' =&gt; array(
                  'rule' =&gt; array('verifyOldPass'),
                  'message' =&gt; 'Please enter correct old password'),
          ),
          'password' =&gt; array(
              'mustNotEmpty' =&gt; array(
                  'rule' =&gt; 'notEmpty',
                  'message' =&gt; 'Please enter password',
                  'on' =&gt; 'create',
                  'last' =&gt; true),
              'complex' =&gt; array(
                  'rule' =&gt; array('complexPassword'),
                  'message' =&gt; 'Password should be six characters long, which should have minimum one alphabet, one number and one special character',
              ),
          ),
          'captcha' =&gt; array(
              'mustMatch' =&gt; array(
                  'rule' =&gt; array('recaptchaValidate'),
                  'message' =&gt; ''),
          )
      );
      $this-&gt;validate = $validate1;
      return $this-&gt;validates();
  }
  </code></pre>
  
  <p>Its gives me error</p>
  
  <blockquote>
    <p>Error: SQLSTATE[42000]: Syntax error or access violation: 1064 You
    have an error in your SQL syntax; check the manual that corresponds to
    your MySQL server version for the right syntax to use near
    'AddEditValidate' at line 1</p>
    
    <p>SQL Query: AddEditValidate</p>
  </blockquote>
  
  <p>Please help me.</p>
  
  <p>Thanks</p>