Looks to me like the error is to do with the lines before line 60.
Looking back at Amit's suggestion, the validate array wasn't ended properly
(I think due to it being a impartial example)
'confirm_password' => array(
'notEmpty' => array(
'rule' => 'notEmpty',
'message' => 'This field cannot be blank.',
'last' => true,
),
'lengthCheck' => array(
'rule' => '/^.{6,40}$/',
'message' => 'Minimum password 6
characters.',
'last' => true,
),
'confirmed' => array(
'rule' => 'confirmPassword'
'message' => 'Both passwords should match.'
),
),
Should be something like this
var $validate = array(
'confirm_password' => array(
'notEmpty' => array(
'rule' => 'notEmpty',
'message' => 'This field cannot be blank.',
'last' => true
),
'lengthCheck => array(
'rule' => '/^.{6,40}$/',
'message' => 'Minimum password 6 characters.',
'last' => true
),
'confirmed' => array(
'rule' => 'confirmPassword',
'message' => 'Both passwords should match.'
)
)
);
function confirmPassword() {
...
}
Be sure to include any other validation and the function.
On 21 December 2010 15:12, John Maxim <[email protected]> wrote:
> Just to repost the error message:
>
> Parse error: parse error, expecting `')'' in C:\wamp\www\cakephp\app
> \models\user.php on line 60
>
> On Dec 21, 11:11 pm, John Maxim <[email protected]> wrote:
> > Hi Stephen,
> >
> > wow it gives exactly the same error. Where it points at line 60
> >
> > ==>Line 60 ===> function confirmPassword() {
> > $hash =
> Security::hash($this->data[$this->alias]
> > ['confirm_password'], null, true);
> >
> > if($this->data[$this->alias]['password'] ==
> $hash) {
> > return true;
> >
> > return false;
> >
> > }
> >
> > Same like the previous one. It points at the same line where the
> > function name is...
> >
> > On Dec 21, 11:01 pm, Stephen <[email protected]> wrote:
> >
> > >http://api.cakephp.org/view_source/security/#line-113
> >
> > > Try something like this maybe?
> >
> > > function confirmPassword() {
> > > $hash =
> Security::hash($this->data[$this->alias]['confirm_password'],
> > > null, true);
> >
> > > if($this->data[$this->alias]['password'] == $hash) {
> > > return true;
> > > }
> >
> > > return false;
> >
> > > }
> >
> > > On 21 December 2010 14:51, John Maxim <[email protected]> wrote:
> >
> > > > I checked many times, based on your explanation here:
> >
> > > > (($variable) == condition(param1, param2, param3))
> >
> > > > Even cleared browser cookies...
> >
> > > > and it gives exactly the same error.
> >
> > > > -------------the whole piece of model code:
> > > > class User extends AppModel
> > > > {
> > > > var $name = 'User';
> >
> > > > var $validate = array (
> >
> > > > 'username' => array(
> > > > 'notEmpty' => array(
> > > > 'rule' => 'notEmpty',
> > > > 'message' => 'This field cannot be
> blank.',
> > > > 'last' => true,
> > > > ),
> > > > 'uniqueCheck' => array(
> > > > 'rule' => 'isUnique',
> > > > 'message' => 'That username has
> already been
> > > > taken.',
> > > > 'last' => true,
> > > > ),
> > > > 'lengthCheck' => array(
> > > > 'rule' => '/^.{6,40}$/',
> > > > 'message' => 'Minimum username 6
> > > > characters.',
> > > > 'last' => true,
> > > > ),
> > > > ),
> >
> > > > 'email' => array(
> > > > 'notEmpty' => array(
> > > > 'rule' => 'notEmpty',
> > > > 'message' => 'This field cannot be blank.',
> > > > 'last' => true,
> > > > ),
> > > > 'email' => array(
> > > > 'rule' => 'email',
> > > > 'message' => 'That is not a valid email address.',
> > > > 'last' => true,
> > > > ),
> > > > ),
> >
> > > > 'confirm_password' => array(
> > > > 'notEmpty' => array(
> > > > 'rule' => 'notEmpty',
> > > > 'message' => 'This field cannot be
> blank.',
> > > > 'last' => true,
> > > > ),
> > > > 'lengthCheck' => array(
> > > > 'rule' => '/^.{6,40}$/',
> > > > 'message' => 'Minimum password 6
> > > > characters.',
> > > > 'last' => true,
> > > > ),
> > > > 'checkMatch' => array(
> > > > 'rule' => 'confirmPassword',
> > > > 'message' => 'Both passwords should
> match.',
> > > > 'last' => true,
> > > > ),
> >
> > > > ),
> >
> > > > function confirmPassword() {
> > > > return (($this->data[$this->alias]['password']) ==
> >
> > > > Security::hash($this->data[$this->alias]['confirm_password'], null,
> > > > true));
> >
> > > > }
> >
> > > > );
> >
> > > > }
> >
> > > > ------------
> >
> > > > Just in case I might done wrong else where but I don't think so. See
> > > > somewhere else wrong ?
> >
> > > > On Dec 21, 10:45 pm, John Maxim <[email protected]> wrote:
> > > > > Yes, the error is the same even using your code and I've checked a
> few
> > > > > times. It gave the same error.
> >
> > > > > function confirmPassword() {
> > > > > return (($this->data[$this->alias]['password']) ==
> >
> > > > Security::hash($this->data[$this->alias]['confirm_password'], null,
> > > > > true));
> >
> > > > > }
> >
> > > > > On Dec 21, 10:32 pm, Stephen <[email protected]>
> wrote:
> >
> > > > > > To me it seems the bracket is misplaced.
> >
> > > > > > You were doing this
> >
> > > > > > (($variable) == condition(param1), param2, param3)
> >
> > > > > > The parameters for Security::hash should be contained within the
> > > > brackets.
> >
> > > > > > (($variable) == condition(param1, param2, param3))
> >
> > > > > > Is the error the same?
> >
> > > > > > On 21 December 2010 14:18, John Maxim <[email protected]> wrote:
> >
> > > > > > > I crossed replied with your previous message Stephen, sorry,
> >
> > > > > > > and I tried your code it gave the same error.
> >
> > > > > > > Thanks for your time, too..
> >
> > > > > > > What is your thoughts on this error ?
> >
> > > > > > > On Dec 21, 10:13 pm, John Maxim <[email protected]> wrote:
> > > > > > > > I tried putting it outside the array validation where it
> gives
> > > > parsing
> > > > > > > > error without the bracket sign "("
> >
> > > > > > > > On Dec 21, 9:58 pm, John Maxim <[email protected]> wrote:
> >
> > > > > > > > > Hi, thanks Amit, but
> >
> > > > > > > > > I got an error here:
> >
> > > > > > > > > Parse error: parse error, expecting `')'' in
> > > > C:\wamp\www\cakephp\app
> > > > > > > > > \models\user.php on line 66
> >
> > > > > > > > > On line 66 is:
> >
> > > > > > > > > function confirmPassword()
> > > > > > > > > {
> > > > > > > > > return
> > > > (($this->data[$this->alias]['password'])
> > > > > > > ==
> > > > > > > > >
> Security::hash($this->data[$this->alias]['confirm_password']),
> > > > null,
> > > > > > > > > true);
> > > > > > > > > }
> >
> > > > > > > > > I modified a few times to include and exclude some of the
> > > > brackets,
> > > > > > > > > but it gives the same error as shown above. *I used Amit
> code as
> > > > > > > > > originally and it started with the error above.
> >
> > > > > > > > > Do I add this function inside the var $validate = array (
> > > > );
> >
> > > > > > > > > or it has to be outside the array validation ?
> >
> > > > > > > > > Can someone look where the function go wrong ?
> >
> > > > > > > > > On Dec 21, 5:41 pm, Amit Badkas <[email protected]>
> wrote:
> >
> > > > > > > > > > Hi,
> >
> > > > > > > > > > You need to use custom validation method for this in your
> > > > model,
> > > > > > > something
> > > > > > > > > > like
> >
> > > > > > > > > > 'confirm_password' => array(
> > > > > > > > > > 'notEmpty' => array(
> > > > > > > > > > 'rule' => 'notEmpty',
> > > > > > > > > > 'message' => 'This field
> cannot
> > > > be
> > > > > > > blank.',
> > > > > > > > > > 'last' => true,
> > > > > > > > > > ),
> > > > > > > > > > 'lengthCheck' => array(
> > > > > > > > > > 'rule' => '/^.{6,40}$/',
> > > > > > > > > > 'message' => 'Minimum
> password
> > > > 6
> > > > > > > > > > characters.',
> > > > > > > > > > 'last' => true,
> > > > > > > > > > ),
> > > > > > > > > > 'confirmed' => array(
> > > > > > > > > > 'rule' =>
> 'confirmPassword'
> > > > > > > > > > 'message' => 'Both
> passwords
> > > > should
> > > > > > > match.'
> > > > > > > > > > ),
> > > > > > > > > > ),
> >
> > > > > > > > > > function confirmPassword()
> > > > > > > > > > {
> > > > > > > > > > return ($this->data[$this->alias]['password'] ==
> > > > > > > > > >
> Security::hash($this->data[$this->alias]['confirm_password'],
> > > > null,
> > > > > > > true));
> >
> > > > > > > > > > }
> >
> > > > > > > > > > FYI, password hash mechanism uses Security::hash(),
> that's why
> > > > we
> > > > > > > also need
> > > > > > > > > > to hash our confirmed password for comparison.
> >
> > > > > > > > > > Hope this helps.
> >
> > > > > > > > > > Amit Badkas
> >
> > > > > > > > > > PHP Applications for E-Biz:http://www.sanisoft.com
> >
> > > > > > > > > > On Tue, Dec 21, 2010 at 2:39 PM, John Maxim <
> [email protected]
> >
> > > > > > > wrote:
> > > > > > > > > > > Hi,
> >
> > > > > > > > > > > Do you know how to match value in password with
> > > > confirm_password ?
> > > > > > > I
> > > > > > > > > > > tried equalTo but it is meant for fixed value ?
> >
> > > > > > > > > > > I have tried what you suggested before this, since your
> first
> > > > post,
> > > > > > > I
> > > > > > > > > > > understand, however, the passwords matching for the 2
> > > > password
> > > > > > > fields
> > > > > > > > > > > using validation--do you think it is possible without
> > > > creating a
> > > > > > > > > > > function ?
> >
> > > > > > > > > > > @previous post, I was referring to the Solution 1 where
> it
> > > > created
> > > > > > > a
> > > > > > > > > > > function, I think it was put in model.
> >
> > > > > > > > > > > Solution 2 is something what I'm trying to do
> half-way....
> >
> > ...
> >
> > read more ยป
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others
> with their CakePHP related questions.
>
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<cake-php%[email protected]>For
> more options, visit this group at
> http://groups.google.com/group/cake-php?hl=en
>
--
Kind Regards
Stephen @ NinjaCoderMonkey
www.ninjacodermonkey.co.uk
Check out the new CakePHP Questions site http://cakeqs.org and help others with
their CakePHP related questions.
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en